Skip to content
Snippets Groups Projects
Commit 48cbf2cf authored by Daniel Brown's avatar Daniel Brown
Browse files

watcher thread now start the test thread when ready, stops the watcher trying...

watcher thread now start the test thread when ready, stops the watcher trying to join the test thread before it is ready
parent 0ce64fb3
Branches
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ class FinesseProcessWatcher(Thread): ...@@ -39,6 +39,7 @@ class FinesseProcessWatcher(Thread):
self.process_to_watch = process self.process_to_watch = process
def run(self): def run(self):
try:
global schedule_lock,current_test,scheduled_tests, watcher global schedule_lock,current_test,scheduled_tests, watcher
if self.process_to_watch is None: if self.process_to_watch is None:
...@@ -48,11 +49,11 @@ class FinesseProcessWatcher(Thread): ...@@ -48,11 +49,11 @@ class FinesseProcessWatcher(Thread):
# raise Exception("Tried to watch something which wasn't a FinesseTestProcess") # raise Exception("Tried to watch something which wasn't a FinesseTestProcess")
print "Watcher is watching", self.process_to_watch print "Watcher is watching", self.process_to_watch
self.process_to_watch.start()
self.process_to_watch.join() self.process_to_watch.join()
print "Watcher is continuing" print "Watcher is continuing"
try:
# once done check if any other tests need to be ran # once done check if any other tests need to be ran
schedule_lock.acquire() schedule_lock.acquire()
...@@ -62,13 +63,14 @@ class FinesseProcessWatcher(Thread): ...@@ -62,13 +63,14 @@ class FinesseProcessWatcher(Thread):
watcher = FinesseProcessWatcher() watcher = FinesseProcessWatcher()
watcher.setProcessToWatch(current_test) watcher.setProcessToWatch(current_test)
watcher.start() watcher.start()
current_test.start()
else: else:
print "Watcher found no more tests to run" print "Watcher found no more tests to run"
current_test = None current_test = None
watcher = None
finally:
schedule_lock.release() schedule_lock.release()
@app.route('/finesse/cancel_test_<id>', methods=["POST"]) @app.route('/finesse/cancel_test_<id>', methods=["POST"])
def finesse_cancel_test(id): def finesse_cancel_test(id):
print id print id
...@@ -150,12 +152,11 @@ def finesse_start_test(): ...@@ -150,12 +152,11 @@ def finesse_start_test():
if current_test is None: if current_test is None:
print "running test" print "running test"
current_test = test current_test = test
# create watcher thread which will start the test
# when ready
watcher = FinesseProcessWatcher() watcher = FinesseProcessWatcher()
watcher.setProcessToWatch(test) watcher.setProcessToWatch(test)
watcher.start() watcher.start()
test.start()
else: else:
print "queuing test" print "queuing test"
scheduled_tests.append(test) scheduled_tests.append(test)
......
...@@ -11,7 +11,7 @@ REQUIREMENTS = [i.strip() for i in open("requirements.txt").readlines()] ...@@ -11,7 +11,7 @@ REQUIREMENTS = [i.strip() for i in open("requirements.txt").readlines()]
setup( setup(
name='PyKat', name='PyKat',
version='0.0.2', version='0.0.3',
author='Daniel Brown', author='Daniel Brown',
author_email='ddb@star.sr.bham.ac.uk', author_email='ddb@star.sr.bham.ac.uk',
packages=['pykat','pykat.gui','pykat.gui.resources'], packages=['pykat','pykat.gui','pykat.gui.resources'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment