Add setup and teardown callbacks#14
Conversation
|
Any feedback on this PR? |
|
I've made some minor changes to this and published a new release |
|
@sheharyarn receiving only the arguments in the setup/teardown callbacks defeats the purpose of the PR since it makes those callbacks practically indistinguishable from the current perform/on_success/on_failure callbacks. My use case is a custom logger backend that needs the job's id during setup and teardown and I can see many other use cases that would benefit from having access to the full |
|
I thought about this more and you're right. I should've discussed this more before making those changes. I've reverted them and pushed a new release with this. Thanks again! |
|
Cool, thanks 👍 |
This feature introduces two new worker callbacks,
on_setupandon_teardown, that expose the whole job struct, not just its arguments. My intended use case was to add a custom per-job logger backend, but it can be used to run any setup / cleanup code that depends on a job's id, pid, etc.This PR also fixes a timing dependent test intermittence which happened when a spawned job task took longer than 3ms to finish. This is accomplished by introducing a
wait_for_childrenhelper which monitors the spawned tasks.