Skip to content

A minimalistic asyncio event loop based on the GLib main event loop

License

Notifications You must be signed in to change notification settings

begnac/gasyncio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gasyncio - A minimalistic asyncio event loop based on the GLib main event loop

Defines GAsyncIOEventLoopPolicy and GAsyncIOEventLoop.

  • gasyncio.start_slave_loop() will set up the asyncio event loop to be run by the GLib main event loop. While the GLib main event loop is running, e.g., inside a running Gio.Application, code based on asyncio will run normally.
  • gasyncio.stop_slave_loop() will undo this.
  • run_until_complete will execute in its own GLib.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()

About

A minimalistic asyncio event loop based on the GLib main event loop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages