Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
queue_processors: Include queue name in the timeout exception.
Alex Vandiver5b45f8a128c2
diff --git a/zerver/tests/test_queue_worker.py b/zerver/tests/test_queue_worker.pyindex 9e6e1b86979..0c64c4d0901 100644--- a/zerver/tests/test_queue_worker.py+++ b/zerver/tests/test_queue_worker.py@@ -735,7 +735,7 @@ class WorkerTest(ZulipTestCase):worker.start()self.assertEqual(m.records[0].message,- "Timed out after 1 seconds processing 1 events in queue timeout_worker",+ "Timed out in timeout_worker after 1 seconds processing 1 events",)self.assertIn(m.records[0].stack_info, m.output[0])@@ -775,7 +775,7 @@ class WorkerTest(ZulipTestCase):worker.start()self.assertEqual(m.records[0].message,- "Timed out after 1 seconds while fetching URLs for message 15: ['first', 'second']",+ "Timed out in timeout_worker after 1 seconds while fetching URLs for message 15: ['first', 'second']",)def test_worker_noname(self) -> None:diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.pyindex 5e9de28bf06..ff3101d4ec4 100644--- a/zerver/worker/queue_processors.py+++ b/zerver/worker/queue_processors.py@@ -109,12 +109,13 @@ logger = logging.getLogger(__name__)class WorkerTimeoutException(Exception):- def __init__(self, limit: int, event_count: int) -> None:+ def __init__(self, queue_name: str, limit: int, event_count: int) -> None:+ self.queue_name = queue_nameself.limit = limitself.event_count = event_countdef __str__(self) -> str:- return f"Timed out after {self.limit * self.event_count} seconds processing {self.event_count} events"+ return f"Timed out in {self.queue_name} after {self.limit * self.event_count} seconds processing {self.event_count} events"class InterruptConsumeException(Exception):@@ -350,7 +351,7 @@ class QueueProcessingWorker(ABC):def timer_expired(self, limit: int, events: List[Dict[str, Any]], signal: int, frame: FrameType) -> None:- raise WorkerTimeoutException(limit, len(events))+ raise WorkerTimeoutException(self.queue_name, limit, len(events))def _handle_consume_exception(self, events: List[Dict[str, Any]], exception: Exception) -> None:if isinstance(exception, InterruptConsumeException):@@ -369,9 +370,7 @@ class QueueProcessingWorker(ABC):if isinstance(exception, WorkerTimeoutException):with sentry_sdk.push_scope() as scope:scope.fingerprint = ["worker-timeout", self.queue_name]- logging.exception(- "%s in queue %s", str(exception), self.queue_name, stack_info=True- )+ logging.exception(exception, stack_info=True)else:logging.exception("Problem handling data on queue %s", self.queue_name, stack_info=True@@ -838,7 +837,8 @@ class FetchLinksEmbedData(QueueProcessingWorker):event = events[0]logging.warning(- "Timed out after %s seconds while fetching URLs for message %s: %s",+ "Timed out in %s after %s seconds while fetching URLs for message %s: %s",+ self.queue_name,limit,event["message_id"],event["urls"],