-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: There is no current event loop in thread 'Thread-X' #689
Comments
Could you provide complete traceback? The chunk here doesn't show the caller of |
Thank you @ods for a quick response. Here is traceback:
|
Hi @kgaikwad, sorry about the long wait. In the latest release, we introduced several implicit loop fixes, so that will get the loop that is currently running your code using "asyncio.get_running_loop()". Explicit loop argument behaviour is deprecated for most of asyncio high-level operations, so we had to clean that up, but maybe we overdid it a bit. producer = AIOKafkaProducer()
async def produce():
await producer.start()
await producer.produce()
asyncio.run(produce()) You would need to put the initialization inside of an async function too, so either: async def produce():
producer = AIOKafkaProducer()
await producer.start()
await producer.produce()
asyncio.run(produce()) Or using a separate factory: async def init():
return AIOKafkaProducer()
def produce(producer):
producer = AIOKafkaProducer()
await producer.start()
await producer.produce()
producer = asyncio.run()
asyncio.run(produce(producer)) Hope that helps 😓, please let us know if you have any more problems ^^ |
Describe the bug
I am trying to update aiokafa version from 0.6.0 to 0.7.0. I am getting an exception -
RuntimeError: There is no current event loop in thread 'Thread-X'
Expected behaviour
I expect it should run without an error.
Environment (please complete the following information):
python -c "import aiokafka; print(aiokafka.__version__)"
): 0.7.0python -c "import kafka; print(kafka.__version__)"
): 2.0.2kafka-topics.sh --version
):I am using python version
3.6.11
. On aiokafka version upgrade to0.7.0
, faced an issue withdataclasses
module (Exception -ModuleNotFoundError: No module named ‘dataclasses’
). To resolve this, I have explicitly addeddataclasses = "==0.5"
in my Pipfile. Issue got resolved but led to another issue related to event loop.Error logs:
Any pointers?
The text was updated successfully, but these errors were encountered: