Skip to content

Commit

Permalink
Make redis TTL configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
langdal committed Apr 26, 2023
1 parent 2dfca9b commit 4cd4afb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion optimizerapi/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
print('Connecting to' + REDIS_URL)
redis = Redis.from_url(REDIS_URL)
queue = Queue(connection=redis)
if "REDIS_TTL" in os.environ:
TTL = int(os.environ["REDIS_TTL"])
else:
TTL = 500

plt.switch_backend("Agg")

Expand Down Expand Up @@ -67,7 +71,8 @@ def disconnect_check():
print('Found existing job')
except NoSuchJobError:
print('Creating new job')
job = queue.enqueue(do_run_work, body, job_id=job_id)
job = queue.enqueue(do_run_work, body,
job_id=job_id, result_ttl=TTL)
while job.return_value is None:
if disconnect_check():
try:
Expand Down

0 comments on commit 4cd4afb

Please sign in to comment.