Skip to content

Conversation

@cjjacks
Copy link
Contributor

@cjjacks cjjacks commented Oct 23, 2024

Creating a new pull request for #517 without the formatting, linting and docker changes. Additionally incorporating feedback on address specifications

@cjjacks cjjacks changed the title Issue 517 Issue #517 - TCP Support Oct 23, 2024
@cjjacks cjjacks marked this pull request as ready for review October 24, 2024 18:37
@cjjacks cjjacks requested review from a team as code owners October 24, 2024 18:37
@cjjacks
Copy link
Contributor Author

cjjacks commented Oct 24, 2024

Closed the original PR (#521) as I felt it would be cleaner this way. This PR only includes the changes to streams and clients and incorporates the feedback from #521.

The docker based testing harness I used to stress test all the different network components is removed from this pr but can still be found in my personal fork here: https://github.com/cjjacks/AIT-Core/tree/issue-517-docker. The stress can be run by checking out that branch and running make network-test

Additionally, I merged master into this branch to incorporate the linting and formatting changes. All subsequent commits after the merge were done with the pre-commit hooks installed.

Let me know if there is any additional feedback. This time I will rebase and clean up the commit history after feedback so I dont end having to trash the PR if serious changes are needed.

@sonarqubecloud
Copy link

1 similar comment
@sonarqubecloud
Copy link

self.pub = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

def publish(self, msg):
self.pub.connect(self.addr_spec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking if the socket.connect() should be called per-message? Or would it be better to call it once in the constructor?

Also, should re-connection attempt be added in case of broken connection?

if type(output) is int:
self.addr_spec = ("localhost", output)
elif utils.is_valid_address_spec(output):
protocol, hostname, port = output.split(":")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have is_valid_address_spec() , could you please add a parse_address_spec() which replaces string.split(":")

raise (ValueError("TCPInputClient: Invalid Specification"))

def __exit__(self, exc_type, exc_val, exc_tb):
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consolidate into a single method which is called by exit's and del, and consider Niling the fields after they are closed/killed

if stream_type == "inbound":
strm = self._create_inbound_stream(s["stream"])
if type(strm) == PortInputStream:
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this check be made into a static function in streams.py, something like is_server_stream(strm) ?

):
raise ValueError(f"Input stream specification invalid: {parsed_inputs}")

# backwards compatability with original UDP server spec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More a question than request, the output factory warns when discarding excess outputs. Should a similar warning be included here for the non-ZMQStream cases when only first input of many is used?

.. _Stream_config:

TCP/UDP Address Specification:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the doc updates above, could a note be added that states, for backward compatibility, integer ports are treated as 'udp:localhost:port'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants