bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.14k stars 666 forks source link

Fail to connect from another process #1031

Open Drake1804 opened 2 months ago

Drake1804 commented 2 months ago

I want to start my script in a separate process. And Cryptofeed is a part of this new process.

p = multiprocessing.Process(target=init_app)
p.start()

but cryptofeed fails by a timeout:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/cryptofeed/connection_handler.py", line 59, in _create_connection
    async with self.conn.connect() as connection:
  File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__
    return await self.gen.__anext__()
  File "/usr/local/lib/python3.9/site-packages/cryptofeed/connection.py", line 104, in connect
    await self._open()
  File "/usr/local/lib/python3.9/site-packages/cryptofeed/connection.py", line 318, in _open
    self.conn = await websockets.connect(self.address, **self.ws_kwargs)
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 647, in __await_impl_timeout__
    return await self.__await_impl__()
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/async_timeout.py", line 169, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/async_timeout.py", line 252, in _do_exit
    raise asyncio.TimeoutError

I've checked with the websocket-client it establishes a connection without any issues. Am I missing something to make it work? Thank you!