Describe the bug
When running a simple Cryptofeed script with FeedHandler().run(), I get a RuntimeError: There is no current event loop in thread 'MainThread'. The error occurs immediately when trying to start the feed handler.
To Reproduce
Steps to reproduce the behavior:
- Create a Python script with the following code:
from cryptofeed.exchanges import Binance
from cryptofeed.defines import CANDLES
from cryptofeed import FeedHandler
async def candle_callback(c, receipt_timestamp):
print(f"Candle received at {receipt_timestamp}: {c}")
f = FeedHandler()
f.add_feed(
Binance(
symbols=["BTC-USDT"],
channels=[CANDLES],
callbacks={CANDLES: candle_callback},
)
)
f.run()
- Run the script
- See the error:
Traceback (most recent call last):
File "main.py", line 18, in <module>
f.run()
File "site-packages/cryptofeed/feedhandler.py", line 135, in run
loop = asyncio.get_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages/uvloop/__init__.py", line 206, in get_event_loop
raise RuntimeError(
RuntimeError: There is no current event loop in thread 'MainThread'.
Expected behavior
The feed handler should start successfully and begin receiving candle data from Binance without event loop errors.
Operating System:
Cryptofeed Version
- Version: 2.4.1
- Installation method: PyPI
Python
Describe the bug
When running a simple Cryptofeed script with
FeedHandler().run(), I get aRuntimeError: There is no current event loop in thread 'MainThread'. The error occurs immediately when trying to start the feed handler.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The feed handler should start successfully and begin receiving candle data from Binance without event loop errors.
Operating System:
Cryptofeed Version
Python