From fbd73609148efcfe06251cc425c6ede6780f4f87 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 23 May 2016 16:24:17 +0200 Subject: [PATCH] Fix threading --- yaboli/connection.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yaboli/connection.py b/yaboli/connection.py index adc4983..6d6081d 100644 --- a/yaboli/connection.py +++ b/yaboli/connection.py @@ -93,7 +93,8 @@ class Connection(): """ if self._connect(tries=1): - self._thread = threading.Thread(target=self._run, name=self.room) + self._thread = threading.Thread(target=self._run, + name="{}-{}".format(self.room, int(time.time()))) self._thread.start() return self._thread else: @@ -109,7 +110,7 @@ class Connection(): while not self._stopping: try: self._handle_json(self._ws.recv()) - except WSException: + except (WSException, ConnectionResetError): if not self._stopping: self.disconnect() self._connect() @@ -127,7 +128,7 @@ class Connection(): self._callbacks.call("stop") - if self._thread: + if self._thread and self._thread != threading.current_thread(): self._thread.join() def next_id(self):