Commits

ZyX_I  committed 1dc9ed2

python/aurum/repeatedcmd: Made rc implementation on top of threading work
Not the best variant though: you have to wait up to
*cachetime seconds before thread is actually finished;
and it uses multiprocessing.Value

  • Participants
  • Parent commits d3d5d82

Comments (0)

Files changed (1)

File python/aurum/repeatedcmd.py

     from Queue import Queue
     from threading import Lock
     from threading import Thread as Process
+    def signal(*_):
+        pass
+    SIGTERM=None
+    SIG_DFL=None
 else:
     from multiprocessing import Process, Queue, Value, Lock
     from signal import signal, SIGTERM, SIG_DFL
             raise ProcessHaltedError('Child process is not alive')
         # For some reason process.terminate() sometimes may not seem to work. 
         # This is a workaround. Seems it is no longer needed with 
-        # self.process.join(), just keeping it here
+        # self.process.join(), just keeping it here for multiprocessing.
+
+        # For threading this is the only way to terminate thread (use old 
+        # implementation based on sequence of timers?)
         self.interval.value = -1.0
-        self.process.terminate()
-        # Anti-zombie code
-        self.process.join()
+        self.paused.value = 1
+        try:
+            self.process.terminate()
+            # Anti-zombie code
+            self.process.join()
+        except AttributeError:
+            # Threads do not have .terminate method
+            pass
 
     def pause(self):
         self.paused.value = 1