mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-22 03:58:12 +08:00
#50 removes redis connection argument from pusher process
This commit is contained in:
+3
-2
@@ -165,7 +165,7 @@ class Sentinel(object):
|
||||
return p
|
||||
|
||||
def spawn_pusher(self):
|
||||
return self.spawn_process(pusher, self.task_queue, self.event_out, self.list_key, self.r)
|
||||
return self.spawn_process(pusher, self.task_queue, self.event_out, self.list_key)
|
||||
|
||||
def spawn_worker(self):
|
||||
self.spawn_process(worker, self.task_queue, self.result_queue, Value('f', -1), self.timeout)
|
||||
@@ -287,7 +287,7 @@ class Sentinel(object):
|
||||
Stat(self).save()
|
||||
|
||||
|
||||
def pusher(task_queue, event, list_key=Conf.Q_LIST, r=redis_client):
|
||||
def pusher(task_queue, event, list_key=Conf.Q_LIST):
|
||||
"""
|
||||
Pulls tasks of the Redis List and puts them in the task queue
|
||||
:type task_queue: multiprocessing.Queue
|
||||
@@ -295,6 +295,7 @@ def pusher(task_queue, event, list_key=Conf.Q_LIST, r=redis_client):
|
||||
:type list_key: str
|
||||
"""
|
||||
logger.info(_('{} pushing tasks at {}').format(current_process().name, current_process().pid))
|
||||
r = redis_client
|
||||
while True:
|
||||
try:
|
||||
task = r.blpop(list_key, 1)
|
||||
|
||||
@@ -85,7 +85,7 @@ def test_cluster(r):
|
||||
event = Event()
|
||||
event.set()
|
||||
# Test push
|
||||
pusher(task_queue, event, list_key=list_key, r=r)
|
||||
pusher(task_queue, event, list_key=list_key)
|
||||
assert task_queue.qsize() == 1
|
||||
assert queue_size(list_key=list_key, r=r) == 0
|
||||
# Test work
|
||||
@@ -148,7 +148,7 @@ def test_async(r, admin_user):
|
||||
stop_event.set()
|
||||
# push the tasks
|
||||
for i in range(task_count):
|
||||
pusher(task_queue, stop_event, list_key=list_key, r=r)
|
||||
pusher(task_queue, stop_event, list_key=list_key)
|
||||
assert queue_size(list_key=list_key, r=r) == 0
|
||||
assert task_queue.qsize() == task_count
|
||||
task_queue.put('STOP')
|
||||
@@ -292,8 +292,8 @@ def test_recycle(r):
|
||||
task_queue = Queue()
|
||||
result_queue = Queue()
|
||||
# push two tasks
|
||||
pusher(task_queue, stop_event, list_key=list_key, r=r)
|
||||
pusher(task_queue, stop_event, list_key=list_key, r=r)
|
||||
pusher(task_queue, stop_event, list_key=list_key)
|
||||
pusher(task_queue, stop_event, list_key=list_key)
|
||||
# worker should exit on recycle
|
||||
worker(task_queue, result_queue, Value('f', -1))
|
||||
# check if the work has been done
|
||||
@@ -322,7 +322,7 @@ def test_bad_secret(r, monkeypatch):
|
||||
assert len(stat) == 0
|
||||
assert Stat.get(s.parent_pid, r) is None
|
||||
task_queue = Queue()
|
||||
pusher(task_queue, stop_event, list_key=list_key, r=r)
|
||||
pusher(task_queue, stop_event, list_key=list_key)
|
||||
result_queue = Queue()
|
||||
task_queue.put('STOP')
|
||||
worker(task_queue, result_queue, Value('f', -1), )
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_scheduler(r):
|
||||
stop_event = Event()
|
||||
stop_event.set()
|
||||
# push it
|
||||
pusher(task_queue, stop_event, list_key=list_key, r=r)
|
||||
pusher(task_queue, stop_event, list_key=list_key)
|
||||
assert task_queue.qsize() == 1
|
||||
assert queue_size(list_key=list_key, r=r) == 0
|
||||
task_queue.put('STOP')
|
||||
|
||||
Reference in New Issue
Block a user