Tweak db connection closing to ensure a fresh connection to high frequency called code
This commit is contained in:
@@ -33,6 +33,7 @@ job_types_registry = {}
|
||||
|
||||
class Job(object):
|
||||
def __init__(self, function, job_queue_item):
|
||||
close_connection()
|
||||
# Run sync or launch async subprocess
|
||||
# OR launch 2 processes: monitor & actual process
|
||||
node = Node.objects.myself()
|
||||
@@ -51,8 +52,7 @@ class Job(object):
|
||||
job_queue_item.delete()
|
||||
finally:
|
||||
worker.delete()
|
||||
close_connection()
|
||||
|
||||
|
||||
|
||||
class JobType(object):
|
||||
def __init__(self, name, label, function):
|
||||
|
||||
@@ -30,6 +30,7 @@ class Lock(models.Model):
|
||||
@transaction.commit_on_success
|
||||
def release(self):
|
||||
try:
|
||||
close_connection()
|
||||
lock = Lock.objects.get(name=self.name, creation_datetime=self.creation_datetime)
|
||||
lock.delete()
|
||||
except Lock.DoesNotExist:
|
||||
|
||||
Reference in New Issue
Block a user