Implement start
and stop
lifecycle hooks for the supervisor and workers
#317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a simple first implementation for those. With this, you can register blocks of code to be called after the supervisor finishes booting but right before it forks workers and dispatchers (
start
) and before it starts to shut down, gracefully or immediately (stop
).It works like this:
You can do the same for workers, with registered blocks being called before the worker starts polling (
worker_start
) and right before it shuts down its thread pool (worker_stop
):Any errors raised by these blocks will be passed over to
on_thread_error
and won't be re-raised.