question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`RuntimeError: no running event loop` after upgrading to 0.5.0

See original GitHub issue

Unfortunately, changes in #246 broke the code that relies on creating an instance of janus.Queue outside of the scope of a running event loop, for no obvious reason.

Also, the behavior now contradicts with the behavior of asyncio.Queue.

>>> import asyncio
>>> asyncio.Queue()
<Queue at 0x7f76be085730 maxsize=0>
>>> import janus
>>> janus.Queue()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/projects/project/.venv/lib64/python3.8/site-packages/janus/__init__.py", line 29, in __init__
    self._loop = current_loop()
RuntimeError: no running event loop

Is there any good reason to not just use asyncio.get_event_loop? From performance perspective it shouldn’t be significant.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
martyanovcommented, May 12, 2020

Are there any proofs that asyncio.get_event_loop will be replaced with asyncio.get_running_loop in asyncio.Queue, for example? I mean this will be refactored to use asyncio.get_running_loop. Deprecating and removing the loop argement is ok, but changing the internal behavior will break a lot of people’s code.

0reactions
asvetlovcommented, Aug 4, 2020

The reason is: Queue does not exist without the loop. The current version makes this dependency strict and explicit. Sorry, this is not going to change

Read more comments on GitHub >

github_iconTop Results From Across the Web

"RuntimeError: no running event loop" with "asyncio ...
If there is no running event loop a RuntimeError is raised. This function can only be called from a coroutine or a callback....
Read more >
no running event loop after update to v 8.0 #5274 - GitHub
I had a python script working on v7 but when I update the mitmproxy I face the following problem: File "C:\dv\QA-BizagiProxy\bizproxy.py", ...
Read more >
python asyncio no running event loop - You.com
When dealing with a task, run_until_complete finishing means that the coroutine has finished as well, having either returned a value or raised an...
Read more >
Async IO in Python: A Complete Walkthrough
run () , introduced in Python 3.7, is responsible for getting the event loop, running tasks until they are marked as complete, and...
Read more >
Event Loop — Python 3.11.1 documentation
Raise a RuntimeError if there is no running event loop. This function can only be called from a coroutine or a callback. New...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found