Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle requests in a non-blocking fashion #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sersorrel
Copy link

This means that long-running handler methods (if they are long-running due to a long await) will not prevent further incoming requests from being handled. This means your RPC handlers can use idiomatic Python (just await the thing you're waiting for, and return the result when you have it), rather than having to return as quickly as possible and schedule some notification to be sent back to the client when the result is available.

We still wait for all handlers to complete on shutdown.

Fixes #48

This means that long-running handler methods (if they are long-running
due to a long `await`) will not prevent further incoming requests from
being handled.

We still wait for all handlers to complete on shutdown.
@orweis
Copy link
Contributor

orweis commented Sep 25, 2024

Hi @sersorrel ,
Thank you for the submission and willingness to contribute.

I'm currently inclined to decline this PR, as #48 is not a real issue (has clear workarounds as seen in the discussion there), and risk, testing for the potential side-effects, and breaking-changes (especially for code currently assuming the current behaviour) for the changes here outweigh the benefits of being slightly more idiomatic.

At the least this change needs to be feature flagged (e.g. a variable passed to WebsocketRPCEndpoint.__init__) so code already utilizing this library won't be affected by the change.

I'll review this again later this week with more attention, to consider how and if this can be accepted.

@sersorrel
Copy link
Author

sersorrel commented Sep 25, 2024

No worries. I'm currently testing this with my own application, and am running into some slightly tricky issues (unsure whether there's a bug in the application or in this code), so probably best to leave it for the moment regardless. (this turned out to be a bug in my app)

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.

Long-running RPC handlers block other RPC requests
2 participants