mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-05 06:48:12 +08:00
#76 resets stale db connection on every scheduler ping
This commit is contained in:
+6
-4
@@ -117,8 +117,8 @@ class Sentinel(object):
|
|||||||
self.task_queue = Queue(maxsize=Conf.QUEUE_LIMIT) if Conf.QUEUE_LIMIT else Queue()
|
self.task_queue = Queue(maxsize=Conf.QUEUE_LIMIT) if Conf.QUEUE_LIMIT else Queue()
|
||||||
self.result_queue = Queue()
|
self.result_queue = Queue()
|
||||||
self.event_out = Event()
|
self.event_out = Event()
|
||||||
self.monitor = Process()
|
self.monitor = None
|
||||||
self.pusher = Process()
|
self.pusher = None
|
||||||
if start:
|
if start:
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ class Sentinel(object):
|
|||||||
def reincarnate(self, process):
|
def reincarnate(self, process):
|
||||||
"""
|
"""
|
||||||
:param process: the process to reincarnate
|
:param process: the process to reincarnate
|
||||||
:type process: Process
|
:type process: Process or None
|
||||||
"""
|
"""
|
||||||
if process == self.monitor:
|
if process == self.monitor:
|
||||||
self.monitor = self.spawn_monitor()
|
self.monitor = self.spawn_monitor()
|
||||||
@@ -276,7 +276,7 @@ class Sentinel(object):
|
|||||||
|
|
||||||
def pusher(task_queue, event, broker=None):
|
def pusher(task_queue, event, broker=None):
|
||||||
"""
|
"""
|
||||||
Pulls tasks of the Redis List and puts them in the task queue
|
Pulls tasks of the broker and puts them in the task queue
|
||||||
:type task_queue: multiprocessing.Queue
|
:type task_queue: multiprocessing.Queue
|
||||||
:type event: multiprocessing.Event
|
:type event: multiprocessing.Event
|
||||||
"""
|
"""
|
||||||
@@ -412,6 +412,8 @@ def scheduler(broker=None):
|
|||||||
"""
|
"""
|
||||||
if not broker:
|
if not broker:
|
||||||
broker = get_broker()
|
broker = get_broker()
|
||||||
|
# reset stale db connections
|
||||||
|
db.close_old_connections()
|
||||||
try:
|
try:
|
||||||
for s in Schedule.objects.exclude(repeats=0).filter(next_run__lt=timezone.now()):
|
for s in Schedule.objects.exclude(repeats=0).filter(next_run__lt=timezone.now()):
|
||||||
args = ()
|
args = ()
|
||||||
|
|||||||
Reference in New Issue
Block a user