diff options
author | Guillaume Seguin <guillaume@segu.in> | 2007-12-17 03:13:35 +0100 |
---|---|---|
committer | Guillaume Seguin <guillaume@segu.in> | 2007-12-17 03:13:35 +0100 |
commit | 8b8fc5fe2b496620f5a4958f267475e55f86ee63 (patch) | |
tree | d6f8e43f6fbf9677cdc6e5f757af2541a107844c /tsp.py | |
parent | df55d37c0d43be392ec506d46ea8f7e51c2283ae (diff) | |
download | tsp-8b8fc5fe2b496620f5a4958f267475e55f86ee63.tar.gz tsp-8b8fc5fe2b496620f5a4958f267475e55f86ee63.tar.bz2 |
* Don't completely block algorithm thread while stopping it
Diffstat (limited to 'tsp.py')
-rwxr-xr-x | tsp.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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) |