Skip to content

Commit f758876

Browse files
macdiceCommitfest Bot
authored andcommitted
Wake a cfbot worker when work_queue retry is overdue.
This was already happening anyway due to regular wakeup traffic but it's better to have an explicit check every minute just to crank the handle a bit sooner.
1 parent 014c63c commit f758876

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

cfbot_periodic_minutely.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import cfbot_patch
88
import cfbot_util
99
import cfbot_web
10+
import cfbot_work_queue
1011

1112
import errno
1213
import fcntl
@@ -29,6 +30,8 @@ def try_lock():
2930

3031
def run():
3132
with cfbot_util.db() as conn:
33+
cfbot_work_queue.maybe_trigger_retries(conn)
34+
3235
# get the current Commitfest ID
3336
cfs = cfbot_commitfest_rpc.get_current_commitfests()
3437

cfbot_work_queue.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ def insert_work_queue_if_not_exists(cursor, type, key=None):
5454
insert_work_queue(cursor, type, key)
5555

5656

57+
def maybe_trigger_retries(conn):
58+
# This is called by cfbot_periodic_minutely.py to see if we should wake up
59+
# a worker to handle retries. Not strictly necessary since there is
60+
# regular traffic anyway, but...
61+
cursor = conn.cursor()
62+
cursor.execute("""select 1
63+
from work_queue
64+
where status = 'WORK' and lease < now()
65+
limit 1""")
66+
if cursor.fetchone():
67+
cursor.execute("notify work_queue")
68+
conn.commit()
69+
70+
5771
def process_one_job(conn, fetch_only):
5872
cursor = conn.cursor()
5973
if fetch_only:

0 commit comments

Comments
 (0)