diff --git a/bfxapi/websockets/generic_websocket.py b/bfxapi/websockets/generic_websocket.py index 4f7d482..f5b6269 100644 --- a/bfxapi/websockets/generic_websocket.py +++ b/bfxapi/websockets/generic_websocket.py @@ -7,7 +7,6 @@ import websockets import socket import json import time -import nest_asyncio from threading import Thread, Lock from pyee import AsyncIOEventEmitter @@ -15,7 +14,6 @@ from ..utils.custom_logger import CustomLogger # websocket exceptions from websockets.exceptions import ConnectionClosed, InvalidStatusCode -nest_asyncio.apply() class AuthError(Exception): """ @@ -86,6 +84,8 @@ class GenericWebsocket: thread and connection. """ self._start_new_socket() + while True: + time.sleep(1) def get_task_executable(self): """ @@ -93,10 +93,14 @@ class GenericWebsocket: """ return self._run_socket() + def _start_new_async_socket(self): + asyncio.run(self._run_socket()) + def _start_new_socket(self, socketId=None): if not socketId: socketId = len(self.sockets) - asyncio.run(self._run_socket()) + worker = Thread(target=self._start_new_async_socket) + worker.start() return socketId def _wait_for_socket(self, socket_id): diff --git a/requirements.txt b/requirements.txt index 9f4cfff..5bb3aee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,4 @@ pytest-asyncio==0.15.1 six==1.12.0 pyee==8.0.1 aiohttp==3.4.4 -isort==4.3.21 -nest_asyncio==1.5.1 \ No newline at end of file +isort==4.3.21 \ No newline at end of file