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
2324from django .apps import apps
2425
2526from rq .queue import Queue
@@ -57,15 +58,15 @@ def run_maintenance_tasks(self):
5758class 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