Fix control+c not working

This commit is contained in:
Ammar Askar committed 2012-09-12 05:11:58 +05:00
1 parent 9a715a72b8
commit 9b6a195b6a
2 files changed
+13 -1

No files matched your search

+7
View File
@@ -69,6 +69,10 @@ class ServerConnection(threading.Thread):
self.NoGUI = False self.NoGUI = False
self.window = window self.window = window
def disconnect(self):
self.listener.kill = True
self.socket.close()
def setWindow(self, window): def setWindow(self, window):
self.window = window self.window = window
@@ -214,6 +218,7 @@ class PacketListener(threading.Thread):
self.FileObject = FileObject self.FileObject = FileObject
self.window = window self.window = window
self.encryptedConnection = False self.encryptedConnection = False
self.kill = False
def enableEncryption(self): def enableEncryption(self):
#Create an AES cipher from the previously obtained public key #Create an AES cipher from the previously obtained public key
@@ -234,6 +239,8 @@ class PacketListener(threading.Thread):
def run(self): def run(self):
while True: while True:
if (self.kill):
break
try: try:
response = self.FileObject.read(1) response = self.FileObject.read(1)
if (response == ""): if (response == ""):
+6 -1
View File
@@ -121,7 +121,12 @@ if __name__ == "__main__":
port = 25565 port = 25565
connection = NetworkManager.ServerConnection(None, derp['Username'], passwd, sessionid, host, port) connection = NetworkManager.ServerConnection(None, derp['Username'], passwd, sessionid, host, port)
connection.start() connection.start()
raw_input() while True:
try:
raw_input()
except KeyboardInterrupt, e:
connection.disconnect()
sys.exit(1)
else: else:
app = wx.PySimpleApp() app = wx.PySimpleApp()
Login = GUI.MainFrame(None, -1, "") Login = GUI.MainFrame(None, -1, "")