Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
queue: Let stop() work with LoopQueueProcessingWorker.
Alex Vandiverdf86a564dcf5
diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.pyindex 3ad68d46c2f..99be1540050 100644--- a/zerver/worker/queue_processors.py+++ b/zerver/worker/queue_processors.py@@ -317,11 +317,13 @@ class QueueProcessingWorker(ABC):class LoopQueueProcessingWorker(QueueProcessingWorker):sleep_delay = 0sleep_only_if_empty = True+ is_consuming = Falsedef start(self) -> None: # nocoverageassert self.q is not Noneself.initialize_statistics()- while True:+ self.is_consuming = True+ while self.is_consuming:events = self.q.json_drain_queue(self.queue_name)self.do_consume(self.consume_batch, events)# To avoid spinning the CPU, we go to sleep if there's@@ -330,6 +332,9 @@ class LoopQueueProcessingWorker(QueueProcessingWorker):if not self.sleep_only_if_empty or len(events) == 0:time.sleep(self.sleep_delay)+ def stop(self) -> None:+ self.is_consuming = False+@abstractmethoddef consume_batch(self, events: List[Dict[str, Any]]) -> None:pass