-
Notifications
You must be signed in to change notification settings - Fork 0
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
actor system: low-level signal layer #6
Comments
Turns out, just using a coroutine to interact with the mailbox while having a separate queue for signals is not enough. Both queue must be waited on together, and blocking on one prevents the other from being processed. A few approaches
|
The third approach was implemented as of ff50961 using asyncio. A Trio-based reimplementation could be attempted.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The actor system in concurrency/threads/thread_actor.py needs a low-level signal interface to handle such things as exit signals.
Basically, there needs to be a side-channel beside the mailbox to handle exit signals. Maybe another queue?
The trick is to simultaneously handle events from this low-level signal queue and run user code, which may block waiting on mailbox events.
This suggests the user code has to cooperate with the underlying framework and allow it to process this signal queue alongside running the user code. Two models come to mind:
It could also call
throw(ExitSignalError(signal.reason))
on the generator to give user code a chance to do cleanup before terminating. Or like in erlang, different type of exit signals could have different behaviors, and e.g. a "kill" signal would just break out of the loop and terminate as quickly as possible without giving user code opportunity to cleanup.Con: Harder to integrate with async/await code.
Pro: Simple and flexible: can add new features to framework by adding handler for yielded requests.
The text was updated successfully, but these errors were encountered: