Mercurial > hg > orthanc-tests
comparison Tests/Toolbox.py @ 9:3670535fbd4b
fix external thread
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Jun 2015 13:49:12 +0200 |
parents | 6d645b3011e1 |
children | 5f73008bb873 |
comparison
equal
deleted
inserted
replaced
8:f8d781d1d267 | 9:3670535fbd4b |
---|---|
208 os._exit(-1) | 208 os._exit(-1) |
209 stop_event.wait(0.1) | 209 stop_event.wait(0.1) |
210 | 210 |
211 print 'Stopping the external command' | 211 print 'Stopping the external command' |
212 external.terminate() | 212 external.terminate() |
213 external.communicate() # Wait for the command to stop | |
213 | 214 |
214 def __init__(self, command, env = None): | 215 def __init__(self, command, env = None): |
215 self.thread_stop = threading.Event() | 216 self.thread_stop = threading.Event() |
216 self.thread = threading.Thread(target = self.ExternalCommandFunction, | 217 self.thread = threading.Thread(target = self.ExternalCommandFunction, |
217 args = (10, self.thread_stop, command, env)) | 218 args = (10, self.thread_stop, command, env)) |
218 self.daemon = True | 219 #self.daemon = True |
219 self.thread.start() | 220 self.thread.start() |
220 | 221 |
221 def stop(self): | 222 def stop(self): |
222 self.thread_stop.set() | 223 self.thread_stop.set() |
223 self.thread.join() | 224 self.thread.join() |