Self inflicted wounds using cx_freeze
[progcomp2013.git] / qchess / src / thread_util.py
diff --git a/qchess/src/thread_util.py b/qchess/src/thread_util.py
new file mode 100644 (file)
index 0000000..2c79330
--- /dev/null
@@ -0,0 +1,15 @@
+import threading
+
+# A thread that can be stopped!
+# Except it can only be stopped if it checks self.stopped() periodically
+# So it can sort of be stopped
+class StoppableThread(threading.Thread):
+       def __init__(self):
+               threading.Thread.__init__(self)
+               self._stop = threading.Event()
+
+       def stop(self):
+               self._stop.set()
+
+       def stopped(self):
+               return self._stop.isSet()

UCC git Repository :: git.ucc.asn.au