No running event loop
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.
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.
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.
actually, I've found this https://github.com/dano/aioprocessing it has a queue that works like a charm. <3
I suspect problem as described here https://github.com/aio-libs/janus/pull/438
Any progress of this Issue? Same problem when I creating a queue in the sync function and pass it to the async one.
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)