Skip to content

Commit 2ffc8c3

Browse files
committed
Use blpop for redis, and flush logs
1 parent ffa8f53 commit 2ffc8c3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/worker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
redis_client = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, decode_responses=True)
1212

1313
def process_job(job):
14-
print(f"Processing job: {job}")
14+
print(f"Processing job: {job}", flush=True)
1515
# Simulate the time to send a push notification
16-
time.sleep(1)
16+
time.sleep(20)
1717

1818
def main():
19-
print("Worker started...")
19+
print("Worker started...", flush=True)
2020
while True:
21-
job = redis_client.lpop(QUEUE_NAME)
21+
job = redis_client.blpop(QUEUE_NAME, 100)
2222
if job:
2323
process_job(job)
2424
else:
25-
print("No jobs in queue. Waiting...")
25+
print("No jobs in queue. Waiting...", flush=True)
2626
time.sleep(5)
2727

2828
if __name__ == "__main__":
29-
main()
29+
main()

0 commit comments

Comments
 (0)