summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergiusz Bazański <q3k@q3k.org>2012-11-11 13:22:37 +0100
committerSergiusz Bazański <q3k@q3k.org>2012-11-11 13:22:37 +0100
commit6f6dd4fe4c38a53978736fae07525f30a4a9c208 (patch)
treedb0d8bb8eb69d400f3f092f31425f86d2ebd132e
parent213b8f01eb41c4e402df158b8d85eb3ce74aff50 (diff)
downloadlaserz_und_stuff-6f6dd4fe4c38a53978736fae07525f30a4a9c208.tar.gz
laserz_und_stuff-6f6dd4fe4c38a53978736fae07525f30a4a9c208.tar.bz2
laserz_und_stuff-6f6dd4fe4c38a53978736fae07525f30a4a9c208.zip
Added handling for doing a double-harakiri when a thread quits.
-rw-r--r--Lasers_und_stuff/Cannon.pycbin4919 -> 5322 bytes
-rw-r--r--Lasers_und_stuff/main.py17
2 files changed, 15 insertions, 2 deletions
diff --git a/Lasers_und_stuff/Cannon.pyc b/Lasers_und_stuff/Cannon.pyc
index 3ce4fbc..e880c85 100644
--- a/Lasers_und_stuff/Cannon.pyc
+++ b/Lasers_und_stuff/Cannon.pyc
Binary files differ
diff --git a/Lasers_und_stuff/main.py b/Lasers_und_stuff/main.py
index b296528..0b61c0d 100644
--- a/Lasers_und_stuff/main.py
+++ b/Lasers_und_stuff/main.py
@@ -8,6 +8,8 @@ Created on Nov 10, 2012
import random, pygame, sys
import flask
import threading
+import os
+import signal
from pygame.locals import *
from Cannon import CannonController
from Cannon import Gunpoint
@@ -178,9 +180,20 @@ class Screen:
if __name__ == '__main__':
- t = threading.Thread(target=main)
+ def pygame_runner():
+ try:
+ main()
+ except Exception as e:
+ print "Pygame thread raised exception %s" % str(e)
+ os.kill(os.getpid(), signal.SIGINT)
+ t = threading.Thread(target=pygame_runner)
+
def flask_runner():
- app.run(use_reloader=False)
+ try:
+ app.run(use_reloader=False)
+ except Exception as e:
+ print "Flask thread raised exception %s" % str(e)
+ os.kill(os.getpid(), signal.SIGINT)
t2 = threading.Thread(target=flask_runner)
print "Starting pygame..."