Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

queue_processors: Make timer_expired() a method.

Mateusz Manderac101f3acd66d
diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py
index c60f001c0e0..5720c696f98 100644
--- a/zerver/worker/queue_processors.py
+++ b/zerver/worker/queue_processors.py
@@ -197,10 +197,6 @@ def retry_send_email_failures(
return wrapper
-def timer_expired(limit: int, event_count: int, signal: int, frame: FrameType) -> None:
- raise WorkerTimeoutException(limit, event_count)
-
-
class QueueProcessingWorker(ABC):
queue_name: str
MAX_CONSUME_SECONDS: Optional[int] = 30
@@ -292,7 +288,9 @@ class QueueProcessingWorker(ABC):
try:
signal.signal(
signal.SIGALRM,
- functools.partial(timer_expired, self.MAX_CONSUME_SECONDS, len(events)),
+ functools.partial(
+ self.timer_expired, self.MAX_CONSUME_SECONDS, len(events)
+ ),
)
try:
signal.alarm(self.MAX_CONSUME_SECONDS * len(events))
@@ -339,6 +337,9 @@ class QueueProcessingWorker(ABC):
consume_func = lambda events: self.consume(events[0])
self.do_consume(consume_func, [event])
+ def timer_expired(self, limit: int, event_count: int, signal: int, frame: FrameType) -> None:
+ raise WorkerTimeoutException(limit, event_count)
+
def _handle_consume_exception(self, events: List[Dict[str, Any]], exception: Exception) -> None:
with configure_scope() as scope:
scope.set_context(