Hi Victor, If i use asyncio.sleep instead of create_subprocess_shell, it works find even though i have two event loops. There are no errors; the only warning i get is about the task taking too long (slow_callback_duration is 0.1 while my task takes 2 seconds so the warning is expected).
Here's the program (with two event loops) that works ---------------------------------------------------- import asyncio import logging async def sleepWithAsyncio(loop=None): await asyncio.sleep(2, loop=loop) return True def sleepWithNewLoop(): loop = asyncio.new_event_loop() result = loop.run_until_complete(sleepWithAsyncio(loop)) loop.close() return result async def sleepWithMainLoopAndNewLoop(): result = await sleepWithAsyncio() print("sleep with asyncio in main loop ", result) result = sleepWithNewLoop() print("sleep with asyncio in new 'nested' loop ", result) return result def main(): logging.basicConfig(level=logging.DEBUG) asyncio.get_event_loop().run_until_complete(sleepWithMainLoopAndNewLoop()) asyncio.get_event_loop().close() if __name__ == "__main__": main() ----------------------------------------------------- Thanks, Chetan On Monday, August 10, 2015 at 5:52:39 AM UTC-4, Victor Stinner wrote: > > To me it looks wrong to have two event loops per thread. You must get an > error, at least in debug mode. > > What do you want to do? > > Victor >