Skip to content

Commit

Permalink
Merge pull request #24 from lyxint/kick-job
Browse files Browse the repository at this point in the history
Merge implementation and documentation of the kick-job command.
  • Loading branch information
earl committed Jan 8, 2013
2 parents 5bb96fd + ef9b421 commit ea2e7e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions TUTORIAL.mkd
Expand Up @@ -300,6 +300,18 @@ tell you how many jobs were actually kicked alive again:
>>> beanstalk.kick(42)
0

You can also kick a specific job:

>>> job = beanstalk.reserve()
>>> job.bury()
>>> job.stats()['state']
'buried'
>>> job.kick_job() # or beanstalk.kick_job(job.jid)

The `kick-job` command was introduced in beanstalkd v1.8, please make sure
beanstalkd version >= v1.8 if you want to use
this command.


Inspecting Jobs
---------------
Expand Down
7 changes: 7 additions & 0 deletions beanstalkc.py
Expand Up @@ -154,6 +154,10 @@ def kick(self, bound=1):
"""Kick at most bound jobs into the ready queue."""
return int(self._interact_value('kick %d\r\n' % bound, ['KICKED']))

def kick_job(self, jid):
"""Kick a specific job into the ready queue."""
self._interact('kick-job %d\r\n' % jid, ['KICKED'], ['NOT_FOUND'])

def peek(self, jid):
"""Peek at a job. Returns a Job, or None."""
return self._interact_peek('peek %d\r\n' % jid)
Expand Down Expand Up @@ -277,6 +281,9 @@ def bury(self, priority=None):
self.conn.bury(self.jid, priority or self._priority())
self.reserved = False

def kick_job(self):
self.conn.kick_job(self.jid)

def touch(self):
"""Touch this reserved job, requesting more time to work on it before
it expires."""
Expand Down

0 comments on commit ea2e7e9

Please sign in to comment.