Skip to main content

GLib event loop integration for asyncio

This module provides a Python 3 asyncio event loop implementation that makes use of the GLib event loop. This allows for mixing of asyncio and some GLib based code within the same thread.

Enabling this event loop can be achieved with the following code:

import asyncio
import asyncio_glib
asyncio.set_event_loop_policy(asyncio_glib.GLibEventLoopPolicy())

At this point, asyncio.get_event_loop() will return a GLibEventLoop.

Implementation strategy

To ease maintenance, I have tried to reuse as much of the standard library asyncio code as possible. To this end, I created a GLib implementation of the selectors.BaseSelector API. Combine this with the existing asyncio.SelectorEventLoop class, and we have our event loop implementation.

To test that the event loop is functional, I have reused parts of the standard library test suite to run against the new selector and event loop.

At present the selector sublcasses the private selectors._BaseSelectorImpl class, which is a potential source of future compatibility problems. If that happens, taking a local copy of that code is an option.

Comparison with Gbulb

Gbulb is another implementation of the asyncio event loop on top of GLib. The main differences are:

  • Gbulb dispatches asyncio callbacks directly from the GLib main loop. In contrast, asyncio-glib iterates the GLib main loop until an asyncio event is ready and then has asyncio event loop dispatch the event.

  • Gbulb has some Windows compatibility code, while asyncio-glib has had no testing on that platform.

  • asyncio-glib is an essentially unmodified SelectorEventLoop, so should automatically gain any features from new Python releases.

The asyncio-glib code base is also about one tenth of the size of Gbulb.

Metadata

Release files for asyncio-glib 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncio-glib 0.1
File Size Uploaded
asyncio-glib-0.1.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncio-glib 0.1
File Interpreter ABI Platform
asyncio_glib-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / asyncio-glib-0.1.tar.gz

Download URL asyncio-glib-0.1.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fe3ceb2ba5f541330c07ca1bd7ae792468d625bad1acf5354a3a7a0b9fd87521
BLAKE2b-256 checksum
How to use checksums
241c83477e079cfcfb9cedbfbc905d72fee79604b35eec2a1b749eb9f0181733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

Release files / asyncio_glib-0.1-py3-none-any.whl

Download URL asyncio_glib-0.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cae91a7b5f694927b04b452892c4ad2ec5296ab0d2462587a7d317bdf45ee9b7
BLAKE2b-256 checksum
How to use checksums
90ca60ae11d48c276a5109953b056e78586aecfc7f1fa943ca5f934242bb649f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page