Make parent worker process wait until horse process finishes #457
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.
Worker should wait until horse process finishes.
Current implementation ends up raising a StopRequested exception, therefore stopping the parent process without waiting for the horse process to finish.
python run_worker.py
11:07:33 RQ worker started, version 0.4.6
11:07:33
11:07:33 *** Listening on default...
11:07:33 default: fib.slow_fib(1) (9a94e99a-adbe-430a-a0ab-4656afd477ba)
^C11:07:34 Warm shut down requested.
Traceback (most recent call last):
File "run_worker.py", line 11, in
Worker(q).work()
File "/Users/javier.lopez/Dev/rq_test/src/rq/rq/worker.py", line 367, in work
self.execute_job(job)
File "/Users/javier.lopez/Dev/rq_test/src/rq/rq/worker.py", line 438, in execute_job
os.waitpid(child_pid, 0)
File "/Users/javier.lopez/Dev/rq_test/src/rq/rq/worker.py", line 331, in request_stop
raise StopRequested()
rq.worker.StopRequested
A solution to this issue is to set the Parent Worker process state to "busy" before the os.waitpid call, this change makes parent process wait until horse process finishes.