Skip to content

Commit f0630bf

Browse files
committed
Add timeout to worker
1 parent 355d93c commit f0630bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

optimizerapi/worker.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
else:
1212
REDIS_URL = "redis://localhost:6379"
1313

14+
if "WORKER_TIMEOUT" in os.environ:
15+
WORKER_TIMEOUT = int(os.environ["WORKER_TIMEOUT"])
16+
else:
17+
WORKER_TIMEOUT = 180
18+
1419
if __name__ == "__main__":
1520
redis = Redis.from_url(REDIS_URL)
16-
queue = Queue(connection=redis)
21+
queue = Queue(connection=redis, deafult_timeout=WORKER_TIMEOUT)
1722
Worker(queue).work()

0 commit comments

Comments
 (0)