Skip to content
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

No running event loop #448

Closed
aaronclong opened this issue Oct 25, 2022 · 6 comments · Fixed by #710
Closed

No running event loop #448

aaronclong opened this issue Oct 25, 2022 · 6 comments · Fixed by #710

Comments

@aaronclong
Copy link

aaronclong commented Oct 25, 2022

I am having trouble creating the janus Queue outside of asyncio. It requires me to make dummy background tasks to just create the object, since not running loop exists I am wonder if this could be lazy or allow the loop to be passed in the constructor? It makes sync to async code a tad harder.

@blozano824
Copy link

I was able to use janus v0.4.0 successfully but upgrading to v1.0.0 results in the same code raising RuntimeError: no running event loop. I haven't been able to pin down the exact change that caused this.

@lemonJumps
Copy link

From my understanding it needs an existing asyncio loop in main thread in order to work.
I tried to force it to use a loop from separate thread but it didn't like that.

@lemonJumps
Copy link

actually, I've found this https://github.com/dano/aioprocessing it has a queue that works like a charm. <3

@jettify
Copy link
Member

jettify commented Mar 18, 2023

I suspect problem as described here #438

@ghost
Copy link

ghost commented Mar 21, 2023

Any progress of this Issue? Same problem when I creating a queue in the sync function and pass it to the async one.

@OppOops
Copy link

OppOops commented Jun 17, 2024

Simple way to create janus queue in synchronous code (Python 3.6+).

import asyncio
import janus

def init_janus_queue(loop: asyncio.AbstractEventLoop):
    async def create_queue():
        return janus.Queue()
    return loop.run_until_complete(create_queue())

#create your own loop before initializing, note that the loop must remain the same afterword
#loop = asyncio.new_event_loop()
#asyncio.set_event_loop(loop)

res_queue = init_janus_queue(loop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants