Fix threading
This commit is contained in:
parent
e332053380
commit
fbd7360914
1 changed files with 4 additions and 3 deletions
|
|
@ -93,7 +93,8 @@ class Connection():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self._connect(tries=1):
|
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()
|
self._thread.start()
|
||||||
return self._thread
|
return self._thread
|
||||||
else:
|
else:
|
||||||
|
|
@ -109,7 +110,7 @@ class Connection():
|
||||||
while not self._stopping:
|
while not self._stopping:
|
||||||
try:
|
try:
|
||||||
self._handle_json(self._ws.recv())
|
self._handle_json(self._ws.recv())
|
||||||
except WSException:
|
except (WSException, ConnectionResetError):
|
||||||
if not self._stopping:
|
if not self._stopping:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self._connect()
|
self._connect()
|
||||||
|
|
@ -127,7 +128,7 @@ class Connection():
|
||||||
|
|
||||||
self._callbacks.call("stop")
|
self._callbacks.call("stop")
|
||||||
|
|
||||||
if self._thread:
|
if self._thread and self._thread != threading.current_thread():
|
||||||
self._thread.join()
|
self._thread.join()
|
||||||
|
|
||||||
def next_id(self):
|
def next_id(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue