def test_monitor(): assert Stat.get(0).sentinel == 0 c = Cluster() c.start() stats = monitor(run_once=True) c.stop() assert len(stats) > 0 found_c = False for stat in stats: if stat.cluster_id == c.pid: found_c = True assert stat.uptime() > 0 assert stat.empty_queues() is True break assert found_c is True
def test_monitor(): assert Stat.get(0).sentinel == 0 c = Cluster() c.start() stats = monitor(run_once=True) c.stop() assert len(stats) > 0 found_c = False for stat in stats: if stat.cluster_id == c.pid: found_c = True assert stat.uptime() > 0 assert stat.empty_queues() is True break assert found_c is True
def test_bad_secret(r, monkeypatch): list_key = 'test_bad_secret' async('math.copysign', 1, -1, list_key=list_key) stop_event = Event() stop_event.set() start_event = Event() s = Sentinel(stop_event, start_event, list_key=list_key, start=False) Stat(s).save() # change the SECRET monkeypatch.setattr(Conf, "SECRET_KEY", "OOPS") stat = Stat.get_all(r) 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) result_queue = Queue() task_queue.put('STOP') worker(task_queue, result_queue, Value('f', -1), ) assert result_queue.qsize() == 0 r.delete(list_key)
def test_bad_secret(r, monkeypatch): list_key = 'test_bad_secret' async ('math.copysign', 1, -1, list_key=list_key) stop_event = Event() stop_event.set() start_event = Event() s = Sentinel(stop_event, start_event, list_key=list_key, start=False) Stat(s).save() # change the SECRET monkeypatch.setattr(Conf, "SECRET_KEY", "OOPS") stat = Stat.get_all(r) 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) result_queue = Queue() task_queue.put('STOP') worker( task_queue, result_queue, Value('f', -1), ) assert result_queue.qsize() == 0 r.delete(list_key)
def stat(self): if self.sentinel: return Stat.get(self.pid) return Status(self.pid)
def stat(self): if self.sentinel: return Stat.get(self.pid) return Status(self.pid)