Added handling for doing a double-harakiri when a thread quits.

master
q3k 2012-11-11 13:22:37 +01:00
parent 213b8f01eb
commit 6f6dd4fe4c
2 changed files with 15 additions and 2 deletions

Binary file not shown.

View File

@ -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..."