Skip to content

Commit

Permalink
when pushing a task, a notification will be sent to prevent sleeping …
Browse files Browse the repository at this point in the history
…workers from sleeping forever
  • Loading branch information
DanielCollins committed Oct 29, 2017
1 parent 4aeba02 commit 34cb055
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pgtq.py
Expand Up @@ -49,9 +49,12 @@ def push(self, handler_name, args, kwargs):
serialised_task = psycopg2.extras.Json({'name': handler_name,
'args': args,
'kwargs': kwargs})
channel = "pgtq_{0}_runnable_channel".format(self.name)
notification = "NOTIFY {};".format(channel)
with self.conn:
with self.conn.cursor() as cursor:
cursor.execute(sql, [serialised_task])
cursor.execute(notification)

def pop(self):
"""Remove a task from the start of the queue, returning it."""
Expand Down

0 comments on commit 34cb055

Please sign in to comment.