Skip to content

Commit

Permalink
provides a decent default to let the worker notify the arbiter. and m…
Browse files Browse the repository at this point in the history
…odify example to use it
  • Loading branch information
benoitc committed Aug 8, 2011
1 parent abeddc5 commit ce19400
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 2 additions & 5 deletions examples/hello.py
Expand Up @@ -11,11 +11,8 @@

class MyWorker(Worker):

def run(self):

while True:
print "hello from worker n°%s" % self.pid
time.sleep(1)
def handle(self):
print "hello from worker n°%s" % self.pid


if __name__ == "__main__":
Expand Down
10 changes: 9 additions & 1 deletion pistil/worker.py
Expand Up @@ -9,6 +9,7 @@
import os
import signal
import sys
import time
import traceback


Expand Down Expand Up @@ -65,13 +66,20 @@ def notify(self):
"""
self.tmp.notify()


def handle(self):
raise NotImplementedError

def run(self):
"""\
This is the mainloop of a worker process. You should override
this method in a subclass to provide the intended behaviour
for your particular evil schemes.
"""
raise NotImplementedError()
while True:
self.notify()
self.handle()
time.sleep(0.1)

def on_init_process(self):
""" method executed when we init a process """
Expand Down

0 comments on commit ce19400

Please sign in to comment.