summaryrefslogtreecommitdiff
path: root/tsp.py
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-17 03:13:35 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-17 03:13:35 +0100
commit8b8fc5fe2b496620f5a4958f267475e55f86ee63 (patch)
treed6f8e43f6fbf9677cdc6e5f757af2541a107844c /tsp.py
parentdf55d37c0d43be392ec506d46ea8f7e51c2283ae (diff)
downloadtsp-8b8fc5fe2b496620f5a4958f267475e55f86ee63.tar.gz
tsp-8b8fc5fe2b496620f5a4958f267475e55f86ee63.tar.bz2
* Don't completely block algorithm thread while stopping it
Diffstat (limited to 'tsp.py')
-rwxr-xr-xtsp.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tsp.py b/tsp.py
index 1b55713..1374b67 100755
--- a/tsp.py
+++ b/tsp.py
@@ -27,6 +27,7 @@
import pygtk
pygtk.require ("2.0")
import gtk
+import gobject
gtk.gdk.threads_init ()
@@ -305,8 +306,6 @@ class AlgoThread (threading.Thread):
runner = self.algo.run (best)
while not self.terminate:
path = runner.next ()
- if self.terminate:
- return
if not best or path.length < best.length:
best = path
self.update_best (path = best)
@@ -454,7 +453,10 @@ class AlgoGui (gtk.Window):
def stop (self, *args):
if self.thread:
self.thread.stop ()
- self.thread.join ()
+ self.thread.join (0.1)
+ if self.thread.isAlive ():
+ gobject.timeout_add (100, self.stop)
+ return
self.thread = None
self.gen_button.set_sensitive (True)
self.start_button.set_sensitive (True)