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

Support querying the worker for the currently executing job. #269

Closed
wants to merge 4 commits into from
Closed

Support querying the worker for the currently executing job. #269

wants to merge 4 commits into from

Conversation

mbr
Copy link
Contributor

@mbr mbr commented Sep 25, 2013

Adds the possibility for pipelining (similar to Job.save and Job.delete) by adding optional pipeline=None parameters. Upon starting a job, right after setting the 'busy' state, saves the id of the job to be executed. A convenience method for the probably most common use case is also available (Worker.get_current_job()), which returns a Job instance.

I did not implement pipelining at this time, mainly because I am not 100% of the implications. It would also require reordering of the following code:

self.state = 'busy'
job, queue = result

Someone who knows the codebase better could easily add it though.

@selwin
Copy link
Collaborator

selwin commented Oct 16, 2013

I think this is a reasonable feature request and will be really useful for monitoring purposes. What do you think @nvie?

@@ -215,15 +216,41 @@ def register_death(self):
p.expire(self.key, 60)
p.execute()

def set_state(self, new_state):
def set_state(self, new_state, pipeline=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having the pipeline kwarg in these setters is a Good Thing™, but they aren't used when accessed through the .state property. Actually, I don't think it was good design (I'm fully to blame here!) to have implicit IO when setting a property, because both property access and assignment should have side effects.

I'm fine adding this .set_state(..., pipeline=None) change when we stop using it through the .state property, and I think we should remove it (via proper deprecation, that is, for those who rely on it now). Would you feel comfortable adding that, perhaps?

Same goes for the job_id, which I think is a fine addition. So thanks for that!

Use docstring instead of comment. Sorry.
@selwin selwin mentioned this pull request Mar 6, 2014
@selwin
Copy link
Collaborator

selwin commented Mar 6, 2014

Superseded by #319

@selwin selwin closed this Mar 6, 2014
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