added support per py 3.9 and 3.10

This commit is contained in:
itsdeka
2021-11-24 14:34:33 +01:00
parent f78926b2f8
commit abfafbf8cf
5 changed files with 9 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ import websockets
import socket
import json
import time
import nest_asyncio
from threading import Thread, Lock
from pyee import AsyncIOEventEmitter
@@ -14,6 +15,7 @@ from ..utils.custom_logger import CustomLogger
# websocket exceptions
from websockets.exceptions import ConnectionClosed, InvalidStatusCode
nest_asyncio.apply()
class AuthError(Exception):
"""
@@ -94,12 +96,7 @@ class GenericWebsocket:
def _start_new_socket(self, socketId=None):
if not socketId:
socketId = len(self.sockets)
def start_loop(loop):
asyncio.set_event_loop(loop)
loop.run_until_complete(self._run_socket())
worker_loop = asyncio.new_event_loop()
worker = Thread(target=start_loop, args=(worker_loop,))
worker.start()
asyncio.run(self._run_socket())
return socketId
def _wait_for_socket(self, socket_id):