Permalink
Browse files

kick-job command

  • Loading branch information...
ifduyue committed Nov 7, 2012
1 parent 5bb96fd commit 2142824f016fd502646d566ab36d133b159c1739
Showing with 15 additions and 0 deletions.
  1. +8 −0 TUTORIAL.mkd
  2. +7 −0 beanstalkc.py
View
@@ -300,6 +300,14 @@ 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)
+
Inspecting Jobs
---------------
View
@@ -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 2142824

Please sign in to comment.