[Rivet-svn] r2950 - trunk/bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Feb 22 11:07:41 GMT 2011


Author: buckley
Date: Tue Feb 22 11:07:38 2011
New Revision: 2950

Log:
Make make-plots killable (not perfect, but hey ho)

Modified:
   trunk/bin/make-plots

Modified: trunk/bin/make-plots
==============================================================================
--- trunk/bin/make-plots	Tue Feb 22 10:21:10 2011	(r2949)
+++ trunk/bin/make-plots	Tue Feb 22 11:07:38 2011	(r2950)
@@ -1894,7 +1894,10 @@
         global RECVD_KILL_SIGNAL
         while True:
             if RECVD_KILL_SIGNAL is not None:
-               exit(1)
+                ## Empty the queue
+                while not datfiles.empty():
+                    dummy = datfiles.get_nowait()
+                break
             try:
                 datfile = datfiles.get_nowait()
                 rem = datfiles.qsize()
@@ -2034,10 +2037,12 @@
     RECVD_KILL_SIGNAL = None
     def handleKillSignal(signum, frame):
         "Declare us as having been signalled, and return to default handling behaviour"
+        global RECVD_KILL_SIGNAL
         logging.critical("Signal handler called with signal " + str(signum))
         RECVD_KILL_SIGNAL = signum
         signal.signal(signum, signal.SIG_DFL)
     ## Signals to handle
+    signal.signal(signal.SIGINT,  handleKillSignal)
     signal.signal(signal.SIGTERM, handleKillSignal)
     signal.signal(signal.SIGHUP,  handleKillSignal)
     signal.signal(signal.SIGUSR2, handleKillSignal)
@@ -2045,4 +2050,9 @@
     ## Run threads
     for threadnum in range(opts.NUM_THREADS):
         procthread = MkPlotThread()
+        #procthread.daemon = True
         procthread.start()
+
+    import time
+    while not datfiles.empty() and not RECVD_KILL_SIGNAL:
+        time.sleep(0.25)


More information about the Rivet-svn mailing list