From f1391ab29b7d082f83666cc224f8f3b3339a18d2 Mon Sep 17 00:00:00 2001 From: Joseph Crowe Date: Mon, 5 Oct 2015 03:14:48 +0100 Subject: [PATCH] Add an 'exception' attribute to Connection objects recording the reason for termination of the networking thread. --- minecraft/networking/connection.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/minecraft/networking/connection.py b/minecraft/networking/connection.py index 7ce46d8..c25f981 100644 --- a/minecraft/networking/connection.py +++ b/minecraft/networking/connection.py @@ -149,7 +149,6 @@ class Connection(object): self.write_packet(handshake) - class NetworkingThread(threading.Thread): interrupt = False @@ -160,6 +159,12 @@ class NetworkingThread(threading.Thread): self.daemon = True def run(self): + try: + self._run() + except Exception as e: + self.connection.exception = e + + def _run(self): while True: if self.interrupt: break