Browse files

Merge pull request #24 from lyxint/kick-job

Merge implementation and documentation of the kick-job command.
  • Loading branch information...
2 parents 5bb96fd + ef9b421 commit ea2e7e96a517687ef46d71ad354fcc3d376d0b57 @earl committed Jan 8, 2013
Showing with 19 additions and 0 deletions.
  1. +12 −0 TUTORIAL.mkd
  2. +7 −0 beanstalkc.py
View
12 TUTORIAL.mkd
@@ -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
---------------
View
7 beanstalkc.py
@@ -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)
@@ -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."""

0 comments on commit ea2e7e9

Please sign in to comment.