Skip to content

Commit

Permalink
Comments in sleeping worker code
Browse files Browse the repository at this point in the history
  • Loading branch information
kachayev committed Jul 30, 2011
1 parent f60e0d4 commit 75de20f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/env_stub/workers/sleeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
from gearman import GearmanWorker

class SleepingGearmanWorker(GearmanWorker):
'''
Extend standard gearman worker facilities, adding sleeping tic after each jobs poll
You can use `after_poll` method to add some additional facilities to runnig worker,
for example logging, notification and something like this
'''
def after_poll(self, activity):
'''
Called by parent gearman worker after each poll
(we assump that worker is running in loop and can handle serveral jobs worload)
True is return in order "to say" to worker get next job
'''
sleep(settings.STUB_WORKERS_FREQUENCY)
return True

Expand Down

0 comments on commit 75de20f

Please sign in to comment.