Defines GAsyncIOEventLoopPolicy
and GAsyncIOEventLoop
.
gasyncio.start_slave_loop()
will set up theasyncio
event loop to be run by theGLib
main event loop. While theGLib
main event loop is running, e.g., inside a runningGio.Application
, code based onasyncio
will run normally.gasyncio.stop_slave_loop()
will undo this.run_until_complete
will execute in its ownGLib.MainLoop
.
The following should be semantically equivalent:
asyncio.set_event_loop_policy(gasyncio.GAsyncIOEventLoopPolicy())
loop = asyncio.get_event_loop()
loop.start_slave_loop()
loop.run_until_complete(asyncio.sleep(1))
loop.stop_slave_loop()
loop.close()
asyncio.set_event_loop_policy(None)
del loop
gasyncio.start_slave_loop()
asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))
gasyncio.stop_slave_loop()