Skip to content
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

Make parent worker process wait until horse process finishes #457

Merged
merged 1 commit into from
Jan 12, 2015

Conversation

jlopex
Copy link
Contributor

@jlopex jlopex commented Dec 2, 2014

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) when pulling fc5295e on jlopex:block_until_horse_finishes into 2091c60 on nvie:master.

@selwin
Copy link
Collaborator

selwin commented Dec 24, 2014

This PR looks right to me. Will wait until #434 gets into master before I merge this in.

@jlopex
Copy link
Contributor Author

jlopex commented Dec 25, 2014

@selwin sounds good to me 👍

selwin added a commit that referenced this pull request Jan 12, 2015
Make parent worker process wait until horse process finishes
@selwin selwin merged commit eae2c40 into rq:master Jan 12, 2015
@selwin
Copy link
Collaborator

selwin commented Jan 12, 2015

Thanks for the PR!

@jlopex jlopex deleted the block_until_horse_finishes branch September 22, 2016 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants