{"id":20884743,"url":"https://github.com/x42005e1f/aiologic","last_synced_at":"2025-05-12T18:31:34.314Z","repository":{"id":260812600,"uuid":"855461269","full_name":"x42005e1f/aiologic","owner":"x42005e1f","description":"GIL-powered* locking library for Python","archived":false,"fork":false,"pushed_at":"2025-05-10T06:58:35.000Z","size":766,"stargazers_count":37,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-10T07:33:29.059Z","etag":null,"topics":["anyio","async","async-await","asyncio","concurrency","eventlet","gevent","greenlet","library","locking","mypy","python","synchronization","thread-safety","threading","trio"],"latest_commit_sha":null,"homepage":"https://aiologic.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/x42005e1f.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSES/0BSD.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-10T22:52:14.000Z","updated_at":"2025-05-10T06:58:39.000Z","dependencies_parsed_at":"2024-11-02T19:03:33.217Z","dependency_job_id":"af1bb907-f1a6-473d-880f-74b6c76f15a8","html_url":"https://github.com/x42005e1f/aiologic","commit_stats":null,"previous_names":["x42005e1f/aiologic"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x42005e1f%2Faiologic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x42005e1f%2Faiologic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x42005e1f%2Faiologic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x42005e1f%2Faiologic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x42005e1f","download_url":"https://codeload.github.com/x42005e1f/aiologic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253798116,"owners_count":21966010,"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":["anyio","async","async-await","asyncio","concurrency","eventlet","gevent","greenlet","library","locking","mypy","python","synchronization","thread-safety","threading","trio"],"created_at":"2024-11-18T08:11:05.158Z","updated_at":"2025-05-12T18:31:34.301Z","avatar_url":"https://github.com/x42005e1f.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"..\n  SPDX-FileCopyrightText: 2024 Ilya Egorov \u003c0x42005e1f@gmail.com\u003e\n  SPDX-License-Identifier: CC-BY-4.0\n\n.. role:: mod(literal)\n.. role:: func(literal)\n.. role:: data(literal)\n.. role:: const(literal)\n.. role:: class(literal)\n.. role:: meth(literal)\n.. role:: attr(literal)\n.. role:: type(literal)\n.. role:: exc(literal)\n.. role:: obj(literal)\n\n========\naiologic\n========\n\n.. badges-start-marker\n\n|pypi-dw| |pypi-impl| |pypi-pyv| |pypi-types|\n\n.. |pypi-dw| image:: https://img.shields.io/pypi/dw/aiologic\n  :target: https://pypistats.org/packages/aiologic\n  :alt:\n.. |pypi-impl| image:: https://img.shields.io/pypi/implementation/aiologic\n  :target: #features\n  :alt:\n.. |pypi-pyv| image:: https://img.shields.io/pypi/pyversions/aiologic\n  :target: #features\n  :alt:\n.. |pypi-types| image:: https://img.shields.io/pypi/types/aiologic\n  :target: #features\n  :alt:\n\n.. badges-end-marker\n\n.. description-start-marker\n\n**aiologic** is a locking library for tasks synchronization and their\ncommunication. It provides primitives that are both *async-aware* and\n*thread-aware*, and can be used for interaction between:\n\n- async codes (async \u003c-\u003e async) in one thread as regular async primitives\n- async codes (async \u003c-\u003e async) in multiple threads (!)\n- async code and sync one (async \u003c-\u003e sync) in one thread (!)\n- async code and sync one (async \u003c-\u003e sync) in multiple threads (!)\n- sync codes (sync \u003c-\u003e sync) in one thread as regular sync primitives\n- sync codes (sync \u003c-\u003e sync) in multiple threads as regular sync primitives\n\nLet's take a look at the example:\n\n.. code:: python\n\n    import asyncio\n\n    from threading import Thread\n\n    import aiologic\n\n    lock = aiologic.Lock()\n\n\n    async def func(i: int, j: int) -\u003e None:\n        print(f\"thread={i} task={j} start\")\n\n        async with lock:\n            await asyncio.sleep(1)\n\n        print(f\"thread={i} task={j} end\")\n\n\n    async def main(i: int) -\u003e None:\n        await asyncio.gather(func(i, 0), func(i, 1))\n\n\n    Thread(target=asyncio.run, args=[main(0)]).start()\n    Thread(target=asyncio.run, args=[main(1)]).start()\n\nIt prints something like this:\n\n.. code-block::\n\n    thread=0 task=0 start\n    thread=1 task=0 start\n    thread=0 task=1 start\n    thread=1 task=1 start\n    thread=0 task=0 end\n    thread=1 task=0 end\n    thread=0 task=1 end\n    thread=1 task=1 end\n\nAs you can see, tasks from different event loops are all able to acquire\n:class:`aiologic.Lock`. In the same case if you use :class:`asyncio.Lock`, it\nwill raise a :exc:`RuntimeError`. And :class:`threading.Lock` will cause a\ndeadlock.\n\n.. description-end-marker\n\nFeatures\n========\n\n.. features-start-marker\n\n* Python 3.8+ support\n* `CPython \u003chttps://www.python.org/\u003e`_ and `PyPy \u003chttps://pypy.org/\u003e`_ support\n* `Pickling \u003chttps://docs.python.org/3/library/pickle.html\u003e`_ and `weakrefing\n  \u003chttps://docs.python.org/3/library/weakref.html\u003e`_ support\n* Cancellation and timeouts support\n* Optional `Trio-style checkpoints \u003chttps://trio.readthedocs.io/en/stable/\n  reference-core.html#checkpoints\u003e`_:\n\n  * enabled by default for Trio itself\n  * disabled by default for all others\n\n* Only one checkpoint per asynchronous call:\n\n  * exactly one context switch if checkpoints are enabled\n  * zero or one context switch if checkpoints are disabled\n\n* Fairness wherever possible (with some caveats)\n* Thread-safety wherever possible\n* Lock-free implementation\n* Bundled stub files\n\nSynchronization primitives:\n\n* Flags\n* Events: one-time, reusable, and countdown\n* Barriers: single-use, and cyclic\n* Semaphores: counting, and bounded\n* Capacity limiters: borrowable, and reentrant\n* Locks: primitive, bounded, ownable, and reentrant\n* `Readers-writer locks (external) \u003chttps://gist.github.com/x42005e1f/\n  a50d0744013b7bbbd7ded608d6a3845b\u003e`_\n* Condition variables\n* Resource guards\n\nCommunication primitives:\n\n* Queues: FIFO, LIFO, and priority\n\nSupported concurrency libraries:\n\n* `asyncio \u003chttps://docs.python.org/3/library/asyncio.html\u003e`_, `curio \u003chttps://\n  curio.readthedocs.io\u003e`_, `trio \u003chttps://trio.readthedocs.io\u003e`_, and `anyio\n  \u003chttps://anyio.readthedocs.io\u003e`_ (coroutine-based)\n* `eventlet \u003chttps://eventlet.readthedocs.io\u003e`_, and `gevent \u003chttps://\n  www.gevent.org/\u003e`_ (greenlet-based)\n* `threading \u003chttps://docs.python.org/3/library/threading.html\u003e`_\n  (thread-based)\n\nAll synchronization and communication primitives are implemented entirely on\neffectively atomic operations, which gives `an incredible speedup on PyPy\n\u003chttps://gist.github.com/x42005e1f/149d3994d5f7bd878def71d5404e6ea4\u003e`_ compared\nto alternatives from the :mod:`threading` module. All this works because of\nGIL, but per-object locks also ensure that `the same operations are still\natomic \u003chttps://peps.python.org/pep-0703/#container-thread-safety\u003e`_, so\naiologic also works when running in a `free-threaded mode \u003chttps://\ndocs.python.org/3.13/whatsnew/3.13.html#free-threaded-cpython\u003e`_.\n\n.. features-end-marker\n\nInstallation\n============\n\n.. installation-start-marker\n\nInstall from `PyPI \u003chttps://pypi.org/project/aiologic/\u003e`_ (recommended):\n\n.. code:: console\n\n    pip install aiologic\n\nOr from `Anaconda \u003chttps://anaconda.org/conda-forge/aiologic\u003e`_ (stable):\n\n.. code:: console\n\n    conda install conda-forge::aiologic\n\nOr from `GitHub \u003chttps://github.com/x42005e1f/aiologic\u003e`_ (latest):\n\n.. code:: console\n\n    pip install git+https://github.com/x42005e1f/aiologic.git\n\nYou can also use other package managers, such as `mamba \u003chttps://github.com/\nmamba-org/mamba\u003e`_ or `uv \u003chttps://github.com/astral-sh/uv\u003e`_.\n\n.. installation-end-marker\n\nDocumentation\n=============\n\nRead the Docs: https://aiologic.readthedocs.io (official)\n\nDeepWiki: https://deepwiki.com/x42005e1f/aiologic (AI generated)\n\nCommunication channels\n======================\n\nGitHub Discussions: https://github.com/x42005e1f/aiologic/discussions\n\nFeel free to post your questions and ideas here.\n\nSupport\n=======\n\nIf you like aiologic and want to support its development, star `its repository\non GitHub \u003chttps://github.com/x42005e1f/aiologic\u003e`_.\n\n.. image:: https://starchart.cc/x42005e1f/aiologic.svg?variant=adaptive\n  :target: https://starchart.cc/x42005e1f/aiologic\n\nLicense\n=======\n\n.. license-start-marker\n\nThe aiologic library is `REUSE-compliant \u003chttps://api.reuse.software/info/\ngithub.com/x42005e1f/aiologic\u003e`_ and is offered under multiple licenses:\n\n* All original source code is licensed under `ISC \u003chttps://choosealicense.com/\n  licenses/isc/\u003e`_.\n* All original test code is licensed under `0BSD \u003chttps://choosealicense.com/\n  licenses/0bsd/\u003e`_.\n* All documentation is licensed under `CC-BY-4.0 \u003chttps://choosealicense.com/\n  licenses/cc-by-4.0/\u003e`_.\n* All configuration is licensed under `CC0-1.0 \u003chttps://choosealicense.com/\n  licenses/cc0-1.0/\u003e`_.\n\nFor more accurate information, check the individual files.\n\n.. license-end-marker\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx42005e1f%2Faiologic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx42005e1f%2Faiologic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx42005e1f%2Faiologic/lists"}