File tree 1 file changed +9
-0
lines changed
src/grimoirelab/core/scheduler
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 23
23
import typing
24
24
import uuid
25
25
26
+ import django .db
26
27
import django_rq
27
28
import rq .exceptions
28
29
import rq .job
@@ -301,6 +302,10 @@ def _on_success_callback(
301
302
The new arguments for the job are obtained from the result
302
303
of the job object.
303
304
"""
305
+ # After long-running tasks, the connection may be closed.
306
+ # Close unusable connections and let Django reopen them if needed.
307
+ django .db .close_old_connections ()
308
+
304
309
try :
305
310
job_db = find_job (job .id )
306
311
except NotFoundError :
@@ -342,6 +347,10 @@ def _on_failure_callback(
342
347
The new arguments for the job are obtained from the result
343
348
of the job object.
344
349
"""
350
+ # After long-running tasks, the connection may be closed.
351
+ # Close unusable connections and let Django reopen them if needed.
352
+ django .db .close_old_connections ()
353
+
345
354
try :
346
355
job_db = find_job (job .id )
347
356
except NotFoundError :
You can’t perform that action at this time.
0 commit comments