I have two processes; main process and subprocess. In the main process, the asyncio event asyncio runs and the subprocess starts. I want to run another asyncio event loop in a subprocess. I am using the aioprocessing module to start a subprocess.
Subprocess Function:
def subprocess_code(): loop = asyncio.get_event_loop() @asyncio.coroutine def f(): for i in range(10): print(i) yield from asyncio.sleep(1) loop.run_until_complete(f())
But I get an error message:
loop.run_until_complete(f()) File "/usr/lib/python3.4/asyncio/base_events.py", line 271, in run_until_complete self.run_forever() File "/usr/lib/python3.4/asyncio/base_events.py", line 239, in run_forever raise RuntimeError('Event loop is running.') RuntimeError: Event loop is running.
Is it possible to start a new or restart an existing asyncio event asyncio in a subprocess? If so, how?
python python-asyncio
solarw
source share