Skip to content

Conversation

@arist76
Copy link

@arist76 arist76 commented Jul 10, 2025

  • Refactored listen()
    • Now supports a timeout parameter (default: 300s).
    • Cleans up legacy code and yields parsed SSE events directly.
  • Added listen_until_clear(timeout)
    • Waits until a pathClear status is received or timeout is reached.
    • Tries to replicate the behaviour of block().
  • Replaced .listen() calls with .listen_until_clear()

arist76 added 3 commits July 10, 2025 10:14
- changed listen method to a generic generator the yields the status
sent by the server stream.
- implemented listen_until_clear that simulates what block() does but
for server streams insteam of polling.
@luketpeterson
Copy link
Collaborator

When I try to run these changes I get:
ModuleNotFoundError: No module named 'requests_sse'

Obviously I can fetch the module myself, but there must be a way to add the package to some manifest so python knows to fetch it automatically.

@luketpeterson luketpeterson self-requested a review July 13, 2025 07:28
Copy link
Collaborator

@luketpeterson luketpeterson left a comment

Choose a reason for hiding this comment

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

I raised mainly style stuff. I think Adam had opinions on more substantive things in the API design.


def on_error():
raise Exception("error")
print("event stream closed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want to be this chatty, by default. It's handy for debugging, and maybe if we support a "verbose" switch. But otherwise we probably want operations at this level to be silent on the client side. Just my opinion.

python/client.py Outdated

status = msg.get("status")
if status == "pathClear":
print("path cleared")
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above about status chatter

python/client.py Outdated
print("path cleared")
return ""
elif status == "pathForbiddenTemporary":
print("waiting for path to clear")
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above about status chatter

python/client.py Outdated
# _main()
_main_mm2()
# test_sse_status()
# _main_mm2()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's restore the functionality of the client.py main to running MM2 tests.

Perhaps we want to move all tests outside of client.py, so client.py is just a "library" module, and the tests are in another file. That would be what I would do, but I don't come from the Python world so I don't know all the Python standard practices.

python/client.py Outdated
_main_mm2()
# test_sse_status()
# _main_mm2()
test_sse_status()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even if we keep this test in this file, it probably ought to start with '_' so it doesn't look like a public API.

Copy link
Author

Choose a reason for hiding this comment

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

i will resolve the above comments

@arist76
Copy link
Author

arist76 commented Jul 15, 2025

When I try to run these changes I get: ModuleNotFoundError: No module named 'requests_sse'

Obviously I can fetch the module myself, but there must be a way to add the package to some manifest so python knows to fetch it automatically.

I have added a requirements.txt file for the required dependencies. you can start a virtual environment for a separate python environment.

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

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