Skip to content

Commit

Permalink
Added database connection cleanup for cluster_daemon threads
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Apr 8, 2022
1 parent c1b57b3 commit c08dd4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/cluster_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from threading import Lock

from django.utils.timezone import now

from django.db import close_old_connections
from django.conf import settings

import code, traceback, signal, logging
Expand Down Expand Up @@ -246,6 +246,7 @@ def disconnect(self, access_id):
access.save()

logger.info(f"Disconnected cluster access {access_id}")
close_old_connections()

def resume_calc(self, c, attempt_count=1):

Expand All @@ -271,6 +272,8 @@ def resume_calc(self, c, attempt_count=1):
except KeyError: # already deleted when disconnnected from cluster
pass

close_old_connections()

def process_command(self, body):
lines = body.decode("UTF-8").split("&")

Expand Down
2 changes: 1 addition & 1 deletion frontend/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3362,7 +3362,7 @@ def get_calc(calc_id):

in_file = os.path.join(remote_dir, "in.xyz")

logger.info(f"Launching calc {calc_id}")
logger.info(f"Running calc {calc_id}")
try:
ret = f(in_file, calc)
except Exception as e:
Expand Down

0 comments on commit c08dd4b

Please sign in to comment.