Skip to content

Commit cfb1df9

Browse files
committed
Add missing import in worker module #1959
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent f7d8ac9 commit cfb1df9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scancodeio/worker.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222

23+
from django import db as django_db
2324
from django.apps import apps
2425

2526
from rq.queue import Queue
@@ -57,15 +58,15 @@ def run_maintenance_tasks(self):
5758
class ScanCodeIOTlsWorker(ScanCodeIOWorker):
5859
"""
5960
Modified version of RQ Worker including ScanCode.io customizations for
60-
maintainance task and TLS.
61+
maintenance tasks and TLS.
6162
"""
6263

6364
def execute_job(self, job, queue):
6465
"""
65-
Terminate existing connection to avoid issues with TLS.
66+
Terminate existing database connection to avoid issues with TLS.
6667
https://github.com/aboutcode-org/scancode.io/issues/1523
6768
"""
68-
connection.close()
69+
django_db.connection.close()
6970
super().execute_job(job, queue)
7071

7172

@@ -78,7 +79,7 @@ class ScanCodeIOQueue(Queue):
7879
def acquire_maintenance_lock(self) -> bool:
7980
"""Return a boolean indicating if a lock to clean this queue is acquired."""
8081
lock_acquired = self.connection.set(
81-
self.registry_cleaning_key, 1, nx=1, ex=self.cleaning_lock_ttl
82+
self.registry_cleaning_key, 1, nx=True, ex=self.cleaning_lock_ttl
8283
)
8384
if not lock_acquired:
8485
return False

0 commit comments

Comments
 (0)