Fix some typos and bugs in the worker.
This commit is contained in:
parent
a1164269be
commit
4514f5a969
3 changed files with 22 additions and 9 deletions
|
@ -7,7 +7,7 @@ class WorkQueue(object):
|
|||
def __init__(self, queue_name):
|
||||
self.queue_name = queue_name
|
||||
|
||||
def put(message, available_after=0):
|
||||
def put(self, message, available_after=0):
|
||||
"""
|
||||
Put an item, if it shouldn't be processed for some number of seconds,
|
||||
specify that amount as available_after.
|
||||
|
@ -24,7 +24,7 @@ class WorkQueue(object):
|
|||
|
||||
QueueItem.create(**params)
|
||||
|
||||
def get(processing_time=300):
|
||||
def get(self, processing_time=300):
|
||||
"""
|
||||
Get an available item and mark it as unavailable for the default of five
|
||||
minutes.
|
||||
|
@ -35,9 +35,9 @@ class WorkQueue(object):
|
|||
|
||||
# TODO the query and the update should be atomic, but for now we only
|
||||
# have one worker.
|
||||
avaial = QueueItem.select().where(QueueItem.queue_name = self.queue_name,
|
||||
QueueItem.available_after <= now,
|
||||
available_or_expired)
|
||||
avail = QueueItem.select().where(QueueItem.queue_name == self.queue_name,
|
||||
QueueItem.available_after <= now,
|
||||
available_or_expired)
|
||||
|
||||
found = list(avail.limit(1).order_by(QueueItem.available_after))
|
||||
|
||||
|
@ -51,5 +51,5 @@ class WorkQueue(object):
|
|||
|
||||
return None
|
||||
|
||||
def complete(completed_item):
|
||||
def complete(self, completed_item):
|
||||
item.delete_instance()
|
||||
|
|
Reference in a new issue