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.

timeout: Warn if the thread did not exit.

Alex Vandiver3af2c8d9a3aa
diff --git a/zerver/lib/timeout.py b/zerver/lib/timeout.py
index c85d73cc1fa..46ef82c083a 100644
--- a/zerver/lib/timeout.py
+++ b/zerver/lib/timeout.py
@@ -1,4 +1,5 @@
import ctypes
+import logging
import sys
import threading
import time
@@ -82,6 +83,12 @@ def timeout(timeout: float, func: Callable[[], ResultT]) -> ResultT:
# Re-raise the exception we sent, if possible, so the
# stacktrace originates in the slow code
raise thread.exc_info[1].with_traceback(thread.exc_info[2])
+ # If we don't have that for some reason (e.g. we failed to
+ # kill it), just raise from here; the thread _may still be
+ # running_ because it failed to see any of our exceptions, and
+ # we just ignore it.
+ if thread.is_alive():
+ logging.warning("Failed to time out backend thread")
raise TimeoutExpired
if thread.exc_info[1] is not None: