{"id":16652892,"url":"https://github.com/zerointensity/pyawaitable","last_synced_at":"2025-03-31T10:09:47.275Z","repository":{"id":235168591,"uuid":"787426396","full_name":"ZeroIntensity/pyawaitable","owner":"ZeroIntensity","description":"Call asynchronous code from an extension module.","archived":false,"fork":false,"pushed_at":"2025-03-23T13:44:59.000Z","size":3257,"stargazers_count":42,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T16:45:18.696Z","etag":null,"topics":["abi","async","async-functions","asynchronous","asynchronous-functions","c","c-api","c-coroutines","coroutines","cpython-api","extension","extension-module","python"],"latest_commit_sha":null,"homepage":"https://awaitable.zintensity.dev","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZeroIntensity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"ZeroIntensity"}},"created_at":"2024-04-16T13:56:10.000Z","updated_at":"2025-03-23T13:45:01.000Z","dependencies_parsed_at":"2025-02-22T20:24:19.487Z","dependency_job_id":"13628d50-c3eb-4d6c-8328-3bfd088a4970","html_url":"https://github.com/ZeroIntensity/pyawaitable","commit_stats":{"total_commits":320,"total_committers":2,"mean_commits":160.0,"dds":"0.021874999999999978","last_synced_commit":"38ac00f6094d4d8c9b92e805f99d9ceb5f24ea3f"},"previous_names":["zerointensity/pyawaitable"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeroIntensity%2Fpyawaitable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeroIntensity%2Fpyawaitable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeroIntensity%2Fpyawaitable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZeroIntensity%2Fpyawaitable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZeroIntensity","download_url":"https://codeload.github.com/ZeroIntensity/pyawaitable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246372503,"owners_count":20766626,"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":["abi","async","async-functions","asynchronous","asynchronous-functions","c","c-api","c-coroutines","coroutines","cpython-api","extension","extension-module","python"],"created_at":"2024-10-12T09:30:19.856Z","updated_at":"2025-03-31T10:09:47.256Z","avatar_url":"https://github.com/ZeroIntensity.png","language":"C","readme":"# PyAwaitable\n\n## Call asynchronous code from an extension module\n\n[![Build](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/build.yml/badge.svg)](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/build.yml)\n![Tests](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/tests.yml/badge.svg)\n\n-   [Docs](https://pyawaitable.zintensity.dev)\n-   [Source](https://github.com/ZeroIntensity/pyawaitable)\n-   [PyPI](https://pypi.org/project/pyawaitable)\n\n## What is it?\n\nPyAwaitable is the _only_ library to support defining and calling asynchronous Python functions from pure C code.\n\nIt was originally designed to be directly part of CPython; you can read the [scrapped PEP](https://gist.github.com/ZeroIntensity/8d32e94b243529c7e1c27349e972d926) about it. But, since this library only uses the public ABI, it's better fit outside of CPython, as a library.\n\n## Installation\n\nAdd it to your project's build process:\n\n```toml\n# pyproject.toml example with setuptools\n[build-system]\nrequires = [\"setuptools\", \"pyawaitable\"]\nbuild-backend = \"setuptools.build_meta\"\n```\n\nInclude it in your extension:\n\n```py\nfrom setuptools import setup, Extension\nimport pyawaitable\n\nif __name__ == \"__main__\":\n    setup(\n        ...,\n        ext_modules=[Extension(..., include_dirs=[pyawaitable.include()])]\n    )\n```\n\n## Example\n\n```c\n/*\n Equivalent to the following Python function:\n\n async def async_function(coro: collections.abc.Awaitable) -\u003e None:\n    await coro\n\n */\nstatic PyObject *\nasync_function(PyObject *self, PyObject *coro)\n{\n    // Create our transport between the C world and the asynchronous world.\n    PyObject *awaitable = PyAwaitable_New();\n    if (awaitable == NULL) {\n        return NULL;\n    }\n\n    // Mark our Python coroutine, *coro*, for being executed by the event loop.\n    if (PyAwaitable_AddAwait(awaitable, coro, NULL, NULL) \u003c 0) {\n        Py_DECREF(awaitable);\n        return NULL;\n    }\n\n    // Return our transport, allowing *coro* to be eventually executed.\n    return awaitable;\n}\n```\n\n## Copyright\n\n`pyawaitable` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","funding_links":["https://github.com/sponsors/ZeroIntensity"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerointensity%2Fpyawaitable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerointensity%2Fpyawaitable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerointensity%2Fpyawaitable/lists"}