[LNT] r263416 - [lnt] Register signal handlers on the main thread

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 02:46:25 PDT 2016


Author: jamesm
Date: Mon Mar 14 04:46:25 2016
New Revision: 263416

URL: http://llvm.org/viewvc/llvm-project?rev=263416&view=rev
Log:
[lnt] Register signal handlers on the main thread

We've seen tracebacks like the one below on our LNT server, indicating
that previously, the code that adds the signal handler could be executed
by a thread that's not the main thread. Fix this by installing the
signal handler at module load time, which is assumed to always run in
the main thread.

Patch by Kristof Beyls, reviewed by Chris Matthews

http://reviews.llvm.org/D17508

Modified:
    lnt/trunk/lnt/util/async_ops.py

Modified: lnt/trunk/lnt/util/async_ops.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/async_ops.py?rev=263416&r1=263415&r2=263416&view=diff
==============================================================================
--- lnt/trunk/lnt/util/async_ops.py (original)
+++ lnt/trunk/lnt/util/async_ops.py Mon Mar 14 04:46:25 2016
@@ -29,22 +29,21 @@ WORKERS = None  # The worker pool.
 JOBS = []
 
 
-
 def launch_workers():
     """Make sure we have a worker pool ready to queue."""
     global WORKERS
     if not WORKERS:
         note("Starting workers")
-        manager = Manager()         
+        manager = Manager()
         try:
-            current_app.config['mem_logger'].buffer = manager.list(current_app.config['mem_logger'].buffer)
+            current_app.config['mem_logger'].buffer = \
+                manager.list(current_app.config['mem_logger'].buffer)
         except RuntimeError:
             #  It might be the case that we are not running in the app.
             #  In this case, don't bother memory logging, stdout should
             #  sufficent for console mode.
             pass
-        atexit.register(cleanup)
-        signal.signal(signal.SIGTERM, sigHandler)
+
 
 def sigHandler(signo, frame):
     sys.exit(0)
@@ -57,6 +56,11 @@ def cleanup():
         if p.is_alive:
             p.join()
 
+
+atexit.register(cleanup)
+signal.signal(signal.SIGTERM, sigHandler)
+
+
 def async_fieldchange_calc(db_name, ts, run):
     """Run regenerate field changes in the background."""
     func_args = {'run_id': run.id}




More information about the llvm-commits mailing list