Skip to content
Snippets Groups Projects
Commit bde84981 authored by Nicolas Mansard's avatar Nicolas Mansard
Browse files

Merge branch 'master' of github.com:laas/sot-dyninv

parents 44e24e72 3653ab79
No related branches found
No related tags found
No related merge requests found
import signal, threading, time import threading, time
class ThreadInterruptibleLoop(threading.Thread): class ThreadInterruptibleLoop(threading.Thread):
isQuit=False isQuit=False
...@@ -11,7 +11,7 @@ class ThreadInterruptibleLoop(threading.Thread): ...@@ -11,7 +11,7 @@ class ThreadInterruptibleLoop(threading.Thread):
def __init__(self): def __init__(self):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.setSigHandler() self.daemon = True
def quit(self): self.isQuit = True def quit(self): self.isQuit = True
def setPlay(self,mode): def setPlay(self,mode):
...@@ -36,22 +36,17 @@ class ThreadInterruptibleLoop(threading.Thread): ...@@ -36,22 +36,17 @@ class ThreadInterruptibleLoop(threading.Thread):
self.isRunning=False self.isRunning=False
print 'Thread loop will now end.' print 'Thread loop will now end.'
def sigHandler(self,signum, frame):
print 'Catch signal ', signum
signal.signal(signum, self.previousHandler)
self.quit()
def setSigHandler(self):
self.previousHandler = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, (lambda x,y: self.sigHandler(x,y)) )
def start(self): def start(self):
self.setPlay(True) self.setPlay(True)
threading.Thread.start(self) threading.Thread.start(self)
def restart(self): def restart(self):
self.join() self.join()
self.play() self.play()
self.setSigHandler() self.setSigHandler()
threading.Thread.start(self) threading.Thread.start(self)
def loop(self): def loop(self):
None None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment