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

Dont commit on shutdown if task hasnt finished #5

Closed
wants to merge 1 commit into from

Conversation

shashankmehra
Copy link

The issue I faced was that on shutdown of the worker if the worker was processing a task, it would abandon the task in the middle of its processing, and commit the record. This would result in half processed tasks which are never picked up again. Since this is a job queue, I have to make my tasks idempotent regardless, it makes sense to have another worker pick up the task instead of the task getting dropped. I have mitigated this issue for myself using these changes. Not sure if this is the best way to go about it. Please let me know your thoughts. It might also be a good idea to implement a graceful shutdown.

@coveralls
Copy link

coveralls commented Dec 13, 2016

Coverage Status

Coverage decreased (-1.6%) to 98.413% when pulling 4829853 on shashankmehra:missing_tasks into 5f89dd3 on joowani:dev.

@joowani
Copy link
Owner

joowani commented Dec 13, 2016

Hi @shashankmehra,

I appreciate you bringing this to my attention.
In the lastest release, I tweaked things so that consumers commit each time they process a record.
This means we can actually remove the commiting completely from __del__. I went ahead and pushed the change to dev.

I also added a new function Queue.enqueue_with_key(key, func, *args, **kwargs) for convenience. Please test these out and let me know how they fare.

Because I rebased and modified the history, you will have run git reset --hard origin/dev.

Thanks again for your contribution.
Joohwan

@shashankmehra
Copy link
Author

shashankmehra commented Dec 13, 2016

Thanks. Removing the commit from __del__ makes things easier.
enqueue_with_key also makes things easier since I am not forced to create a Job object on my own. I will be able to test it a little later and let you know.

@shashankmehra
Copy link
Author

I was able to test enqueue_with_key and it works out for me. Thanks.

@joowani
Copy link
Owner

joowani commented Dec 13, 2016

That's great to hear! Closing this out.

@joowani joowani closed this Dec 13, 2016
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