{"id":18838639,"url":"https://github.com/beeware/gbulb","last_synced_at":"2025-04-09T13:08:08.577Z","repository":{"id":43750943,"uuid":"39385973","full_name":"beeware/gbulb","owner":"beeware","description":"GLib implementation of PEP 3156","archived":false,"fork":false,"pushed_at":"2024-04-30T23:11:06.000Z","size":554,"stargazers_count":62,"open_issues_count":10,"forks_count":24,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-05-01T19:51:18.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beeware.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["freakboy3742"],"custom":["http://beeware.org/bee/join"]}},"created_at":"2015-07-20T13:39:06.000Z","updated_at":"2024-05-04T03:25:10.907Z","dependencies_parsed_at":"2023-11-12T21:24:09.367Z","dependency_job_id":"6eba7b48-7883-4bad-8381-2c816aa4783b","html_url":"https://github.com/beeware/gbulb","commit_stats":{"total_commits":231,"total_committers":18,"mean_commits":"12.833333333333334","dds":0.6060606060606061,"last_synced_commit":"f7b109d8d029babc9ef924679159fb4080d5fd4a"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beeware%2Fgbulb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beeware%2Fgbulb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beeware%2Fgbulb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beeware%2Fgbulb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beeware","download_url":"https://codeload.github.com/beeware/gbulb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045233,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T02:40:08.945Z","updated_at":"2025-04-09T13:08:08.548Z","avatar_url":"https://github.com/beeware.png","language":"Python","funding_links":["https://github.com/sponsors/freakboy3742","http://beeware.org/bee/join"],"categories":[],"sub_categories":[],"readme":"THIS PROJECT HAS BEEN ARCHIVED\n==============================\n\n**With the release of PyGObject 3.50.0, GBulb is no longer required**. PyGObject\nnow contains native integration with the Python event loop. If you require\nasyncio support in your GTK app, we advise upgrading your project to use the\nnative asyncio API of `PyGObject 3.50.0+ \u003chttps://pypi.org/project/PyGObject/\u003e`__.\n\nExample usage of PyGObject with native asyncio support::\n\n    import asyncio\n\n    import gi\n    gi.require_version(\"Gtk\", \"3.0\")\n\n    from gi.events import GLibEventLoopPolicy\n    from gi.repository import Gtk\n\n    asyncio.set_event_loop_policy(GlibEventLoopPolicy())\n\n    app = Gtk.Application(...)\n    app.run()\n\nThe last published version of this project (`v0.6.6\n\u003chttps://pypi.org/project/gbulb/0.6.6/\u003e`__) is compatible with versions of\nPyGObject prior to 3.50.0, and CPython 3.8-3.13.\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/gbulb.svg\n   :target: https://pypi.python.org/pypi/gbulb\n   :alt: Python Versions\n\n.. |version| image:: https://img.shields.io/pypi/v/gbulb.svg\n   :target: https://pypi.python.org/pypi/gbulb\n   :alt: PyPI Version\n\n.. |maturity| image:: https://img.shields.io/pypi/status/gbulb.svg\n   :target: https://pypi.python.org/pypi/gbulb\n   :alt: Maturity\n\n.. |license| image:: https://img.shields.io/pypi/l/gbulb.svg\n   :target: https://github.com/beeware/gbulb/blob/main/LICENSE\n   :alt: BSD License\n\n.. |ci| image:: https://github.com/beeware/gbulb/workflows/CI/badge.svg?branch=main\n   :target: https://github.com/beeware/gbulb/actions\n   :alt: Build Status\n\n.. |social| image:: https://img.shields.io/discord/836455665257021440?label=Discord%20Chat\u0026logo=discord\u0026style=plastic\n   :target: https://beeware.org/bee/chat/\n   :alt: Discord server\n\ngbulb\n=====\n\n|pyversions| |version| |maturity| |license| |ci| |social|\n\nGbulb is a Python library that implements a `PEP 3156\n\u003chttp://www.python.org/dev/peps/pep-3156/\u003e`__ interface for the `GLib main event\nloop \u003chttps://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html\u003e`__\nunder UNIX-like systems.\n\nAs much as possible, except where noted below, it mimics asyncio's interface.\nIf you notice any differences, please report them.\n\nRequirements\n------------\n\n- python 3.8+\n- pygobject\n- glib\n- gtk+3 (optional)\n\nUsage\n-----\n\nGLib event loop\n~~~~~~~~~~~~~~~\n\nExample usage::\n\n    import asyncio, gbulb\n    gbulb.install()\n    asyncio.get_event_loop().run_forever()\n\nGtk+ event loop *(suitable for GTK+ applications)*\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nExample usage::\n\n    import asyncio, gbulb\n    gbulb.install(gtk=True)\n    asyncio.get_event_loop().run_forever()\n\nGApplication/GtkApplication event loop\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nExample usage::\n\n    import asyncio, gbulb\n    gbulb.install(gtk=True)  # only necessary if you're using GtkApplication\n\n    loop = asyncio.get_event_loop()\n    loop.run_forever(application=my_gapplication_object)\n\nWaiting on a signal asynchronously\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSee examples/wait_signal.py\n\nKnown issues\n------------\n\n- Windows is not supported, sorry. If you are interested in this, please help\n  me get it working! I don't have Windows so I can't test it.\n\nDivergences with PEP 3156\n-------------------------\n\nIn GLib, the concept of event loop is split in two classes: GLib.MainContext\nand GLib.MainLoop.\n\nThe event loop is mostly implemented by MainContext. MainLoop is just a wrapper\nthat implements the run() and quit() functions. MainLoop.run() atomically\nacquires a MainContext and repeatedly calls MainContext.iteration() until\nMainLoop.quit() is called.\n\nA MainContext is not bound to a particular thread, however it cannot be used\nby multiple threads concurrently. If the context is owned by another thread,\nthen MainLoop.run() will block until the context is released by the other\nthread.\n\nMainLoop.run() may be called recursively by the same thread (this is mainly\nused for implementing modal dialogs in Gtk).\n\nThe issue: given a context, GLib provides no ways to know if there is an\nexisting event loop running for that context. It implies the following\ndivergences with PEP 3156:\n\n- ``.run_forever()`` and ``.run_until_complete()`` are not guaranteed to run\n  immediately. If the context is owned by another thread, then they will\n  block until the context is released by the other thread.\n\n- ``.stop()`` is relevant only when the currently running Glib.MainLoop object\n  was created by this asyncio object (i.e. by calling ``.run_forever()`` or\n  ``.run_until_complete()``). The event loop will quit only when it regains\n  control of the context. This can happen in two cases:\n\n  1. when multiple event loop are enclosed (by creating new ``MainLoop``\n     objects and calling ``.run()`` recursively)\n  2. when the event loop has not even yet started because it is still\n     trying to acquire the context\n\nIt would be wiser not to use any recursion at all. ``GLibEventLoop`` will\nactually prevent you from doing that (in accordance with PEP 3156), however\n``GtkEventLoop`` will allow you to call ``run()`` recursively. You should also keep\nin mind that enclosed loops may be started at any time by third-party code\ncalling GLib's primitives.\n\nTesting\n-------\n\nTesting GBulb requires a Linux environment that has GLib and GTK development\nlibraries available.\n\nThe tests folder contains a Dockerfile that defines a complete testing\nenvironment. To use the Docker environment, run the following from the root of\nthe git checkout:\n\n   $ docker buildx build --tag beeware/gbulb:latest --file ./tests/Dockerfile .\n   $ docker run --rm --volume $(PWD):/home/brutus/gbulb:z -it beeware/gbulb:latest\n\nThis will drop you into an Ubuntu 24.04 shell that has Python 3.8-3.13\ninstalled, mounting the current working directory as `/home/brutus/gbulb`. You\ncan use this to create virtual environments for each Python version.\n\nOnce you have an active virtual environment, run:\n\n   (venv) $ pip install -e .[dev]\n   (venv) $ pytest\n\nto run the test suite. Alternatively, you can install tox, and then run:\n\n   # To test a single Python version\n   (venv) $ tox -e py\n\n   # To test Python 3.10 specifically\n   (venv) $ tox -e py310\n\n   # To test all versions\n   (venv) $ tox\n\nCommunity\n---------\n\ngbulb is part of the `BeeWare suite`_. You can talk to the community through:\n\n* `@pybeeware on Twitter \u003chttps://twitter.com/pybeeware\u003e`__\n\n* `Discord \u003chttps://beeware.org/bee/chat/\u003e`__\n\n* The gbulb `Github Discussions forum \u003chttps://github.com/beeware/gbulb/discussions\u003e`__\n\nWe foster a welcoming and respectful community as described in our\n`BeeWare Community Code of Conduct`_.\n\nContributing\n------------\n\nIf you experience problems with gbulb, `log them on GitHub`_. If you\nwant to contribute code, please `fork the code`_ and `submit a pull request`_.\n\n.. _BeeWare suite: http://beeware.org\n.. _BeeWare Community Code of Conduct: http://beeware.org/community/behavior/\n.. _log them on Github: https://github.com/beeware/gbulb/issues\n.. _fork the code: https://github.com/beeware/gbulb\n.. _submit a pull request: https://github.com/beeware/gbulb/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeeware%2Fgbulb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeeware%2Fgbulb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeeware%2Fgbulb/lists"}