-
Notifications
You must be signed in to change notification settings - Fork 22
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
Worker thread refactoring #12
Comments
How do we deal with exceptions in sub-tasks? So far we've been passing around a This involves passing the busclient everywhere, which is aweful. In the test implementation we now have the command/invoker pattern. This passes commands in a single direction. Options:
|
This is ongoing and I’m working on it over the holiday period. The refactoring is largely done and I’m working on getting the tests sorted, plus a number of ‘TODO’s I’ve left in my wake. |
Tests now passing. |
@apollo13 I've just implemented a first pass at the What I didn't say earlier is: I actually think it makes much more sense for this to be a parameter to the listener, rather than a config option. How each service wants to handle errors is a choice for that service. There is no reason that every service should treat event-handling errors the same for a given API. Thanks for the good suggestion 👍 |
I think this is now largely complete. I'll likely merge an do an 0.10.0 alpha1 release soon. |
Merged in commit a8c106d |
Here I will discuss the refactoring of the worker thread system used by Lightbus. I want to refactor this because:
WorkerNotReady
andWorkerDeadlock
errors.ThreadSerializedTask
as this constrictsasyncio
(which thread safety will allow us to do)Requirements
Any solution must provide the following:
How to achieve this
Thread-safety
Thread safety requires that access to global resources is carefully controlled to prevent race conditions. This either requires the removal of global state or – where this is not possible – marshalling of access to it. For example:
Thread safety can be provided though mechanisms such as locking or queues.
Prevention of deadlock cases
Careful system design is the first step here. If A requires B and B requires A, then no amount of locking primitives will prevent that deadlocking. Rather, removing of blocking (in the threading sense) requirements is an important step.
Queues will likely be the preferable coordination mechanism as they can help keep different system components distinct (not complected).
Minimise other error cases
Hopefully this should fall out of a good design
Does not complect different system components
Again, thoughtful systems design, and isolation of system components.
The text was updated successfully, but these errors were encountered: