Rename task -> job.

Just a gift from a non-mainframe guy to a mainframe guy.  Love is all
about giving ;)
main
Vincent Driessen 13 years ago
parent a5a8925608
commit 834a79814e

@ -20,7 +20,7 @@ class DelayedResult(object):
return self._rv return self._rv
class task(object): class job(object):
def __init__(self, queue='normal'): def __init__(self, queue='normal'):
self.queue = queue self.queue = queue

@ -44,9 +44,9 @@ class Worker(object):
while True: while True:
self.procline('Waiting on %s' % (', '.join(self.queue_names),)) self.procline('Waiting on %s' % (', '.join(self.queue_names),))
queue, msg = conn.blpop(self.queue_keys) queue, msg = conn.blpop(self.queue_keys)
self.fork_and_perform_task(queue, msg) self.fork_and_perform_job(queue, msg)
def fork_and_perform_task(self, queue, msg): def fork_and_perform_job(self, queue, msg):
child_pid = os.fork() child_pid = os.fork()
if child_pid == 0: if child_pid == 0:
random.seed() random.seed()
@ -54,7 +54,7 @@ class Worker(object):
try: try:
self.procline('Processing work since %d' % (time.time(),)) self.procline('Processing work since %d' % (time.time(),))
self._working = True self._working = True
self.perform_task(queue, msg) self.perform_job(queue, msg)
except Exception, e: except Exception, e:
self.log.exception(e) self.log.exception(e)
sys.exit(1) sys.exit(1)
@ -64,7 +64,7 @@ class Worker(object):
os.waitpid(child_pid, 0) os.waitpid(child_pid, 0)
self._working = False self._working = False
def perform_task(self, queue, msg): def perform_job(self, queue, msg):
func, key, args, kwargs = loads(msg) func, key, args, kwargs = loads(msg)
self.procline('Processing %s from %s since %s' % (func.__name__, queue, time.time())) self.procline('Processing %s from %s since %s' % (func.__name__, queue, time.time()))
try: try:

Loading…
Cancel
Save