{"id":13415593,"url":"https://github.com/YoSTEALTH/Liburing","last_synced_at":"2025-03-14T23:30:55.230Z","repository":{"id":54565597,"uuid":"223717917","full_name":"YoSTEALTH/Liburing","owner":"YoSTEALTH","description":"Liburing is Python + Cython wrapper around C Liburing, which is a helper to setup and tear-down io_uring instances.","archived":false,"fork":false,"pushed_at":"2024-05-03T16:57:32.000Z","size":651,"stargazers_count":86,"open_issues_count":1,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-22T15:30:57.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.org/project/liburing/","language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YoSTEALTH.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.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}},"created_at":"2019-11-24T09:06:13.000Z","updated_at":"2024-05-31T01:45:09.529Z","dependencies_parsed_at":"2024-03-03T09:31:40.415Z","dependency_job_id":"1b14f7e3-fc0b-40c9-b12e-ec14d9b94d57","html_url":"https://github.com/YoSTEALTH/Liburing","commit_stats":{"total_commits":325,"total_committers":3,"mean_commits":"108.33333333333333","dds":"0.012307692307692353","last_synced_commit":"f9977c9d5dd2bd5848d347ef41b8923ebb5554b6"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YoSTEALTH%2FLiburing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YoSTEALTH%2FLiburing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YoSTEALTH%2FLiburing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YoSTEALTH%2FLiburing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YoSTEALTH","download_url":"https://codeload.github.com/YoSTEALTH/Liburing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243663309,"owners_count":20327299,"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-07-30T21:00:50.582Z","updated_at":"2025-03-14T23:30:55.222Z","avatar_url":"https://github.com/YoSTEALTH.png","language":"Cython","funding_links":[],"categories":["Libraries","Python"],"sub_categories":["Python"],"readme":"|test-status| |downloads|\n\nLiburing\n========\n\nLiburing is Python + Cython wrapper around `C Liburing`_, which is a helper to setup and tear-down io_uring instances.\n\n* Fast \u0026 scalable asynchronous I/O (storage, networking, ...) interface.\n* ``io_uring`` reduces number of syscalls overhead \u0026 context switches, thus improving speed.\n* ...\n\nGood(old) documentation `Lord of the io_uring`_\n\nCheck out `Shakti`_. It uses ``liburing`` and provides an easy to use Python ``async`` ``await`` Interface.\n\n\nRequires\n--------\n\n    - Linux 6.11+\n    - Python 3.9+\n\n\nIncludes (battery)\n------------------\n\n    - C liburing 2.9+\n\n\nInstall, update \u0026 uninstall (Alpha)\n-----------------------------------\n\nUse `pip`_ to install, upgrade \u0026 uninstall Python wrapper:\n\n.. code-block:: text\n\n    python3 -m pip install liburing             # install\n\n    python3 -m pip install --upgrade liburing   # upgrade\n\n    python3 -m pip uninstall liburing           # uninstall\n\n\nInstall directly from GitHub:\n\n.. code-block:: text\n\n    python3 -m pip install --upgrade git+https://github.com/YoSTEALTH/Liburing\n\n\nTo find out all the class, functions and definitions:\n\n.. code-block:: python\n    \n    import liburing\n\n    print(dir(liburing))  # to see all the importable names (this will not load all the modules)\n    help(liburing)        # to see all the help docs (this will load all the modules.)\n\n\nFind out which ``io_uring`` operations is supported by the kernel:\n\n.. code-block:: python\n    \n    # example/probe.py\n    import liburing\n\n    probe = liburing.probe()\n    print(probe)\n\n\nSimple File Example\n-------------------\n\n.. code-block:: python\n\n    # example/open_write_read_close.py\n    from liburing import O_CREAT, O_RDWR, AT_FDCWD, iovec, io_uring, io_uring_get_sqe, \\\n                         io_uring_prep_openat, io_uring_prep_write, io_uring_prep_read, \\\n                         io_uring_prep_close, io_uring_submit, io_uring_wait_cqe, \\\n                         io_uring_cqe_seen, io_uring_cqe, io_uring_queue_init, io_uring_queue_exit, \\\n                         io_uring_sqe_set_data64, trap_error\n\n\n    def open(ring, cqe, path, flags, mode=0o660, dir_fd=AT_FDCWD):\n        _path = path if isinstance(path, bytes) else str(path).encode()\n        # if `path` is relative and `dir_fd` is `AT_FDCWD`, then `path` is relative\n        # to current working directory. Also `_path` must be in bytes\n\n        sqe = io_uring_get_sqe(ring)  # sqe(submission queue entry)\n        io_uring_prep_openat(sqe, _path, flags, mode, dir_fd)\n        # set submit entry identifier as `1` which is returned back in `cqe.user_data`\n        # so you can keep track of submit/completed entries.\n        io_uring_sqe_set_data64(sqe, 1)\n        return _submit_and_wait(ring, cqe)  # returns fd\n\n\n    def write(ring, cqe, fd, data, offset=0):\n        iov = iovec(data)  # or iovec([bytearray(data)])\n        sqe = io_uring_get_sqe(ring)\n        io_uring_prep_write(sqe, fd, iov.iov_base, iov.iov_len, offset)\n        io_uring_sqe_set_data64(sqe, 2)\n        return _submit_and_wait(ring, cqe)  # returns length(s) of bytes written\n\n\n    def read(ring, cqe, fd, length, offset=0):\n        iov = iovec(bytearray(length))  # or [bytearray(length)]\n        sqe = io_uring_get_sqe(ring)\n        io_uring_prep_read(sqe, fd, iov.iov_base, iov.iov_len, offset)\n        io_uring_sqe_set_data64(sqe, 3)\n        _submit_and_wait(ring, cqe)  # get actual length of file read.\n        return iov.iov_base\n\n\n    def close(ring, cqe, fd):\n        sqe = io_uring_get_sqe(ring)\n        io_uring_prep_close(sqe, fd)\n        io_uring_sqe_set_data64(sqe, 4)\n        _submit_and_wait(ring, cqe)  # no error means success!\n\n\n    def _submit_and_wait(ring, cqe):\n        io_uring_submit(ring)  # submit entry\n        io_uring_wait_cqe(ring, cqe)  # wait for entry to finish\n        result = trap_error(cqe.res)  # auto raise appropriate exception if failed\n        # note `cqe.res` returns results, if ``\u003c 0`` its an error, if ``\u003e= 0`` its the value\n\n        # done with current entry so clear it from completion queue.\n        io_uring_cqe_seen(ring, cqe)\n        return result  # type: int\n\n\n    def main():\n        ring = io_uring()\n        cqe = io_uring_cqe()  # completion queue entry\n        try:\n            io_uring_queue_init(32, ring, 0)\n\n            fd = open(ring, cqe, '/tmp/liburing-test-file.txt', O_CREAT | O_RDWR)\n            print('fd:', fd)\n\n            length = write(ring, cqe, fd, b'hello world')\n            print('wrote:', length)\n\n            content = read(ring, cqe, fd, length)\n            print('read:', content)\n\n            close(ring, cqe, fd)\n            print('closed.')\n        finally:\n            io_uring_queue_exit(ring)\n\n\n    if __name__ == '__main__':\n        main()\n\n\nNote\n----\n    - Try not to use ``from liburing import *`` this will load all the modules at once, unless that's what you want!\n\n\nCython Note\n-----------\n    - You can ``cimport`` ``liburing`` directly into your project if you are planning on compiling your project as well.\n    - There is also ``src/liburing/lib`` directory with raw ``.pxd`` header files.\n    - All raw ``C`` wrapped function, enum, struct, defines starts with ``__``, not including anything that's ``ctypedef``. This is to prevent naming confusion between whats ``C`` and ``Cython`` side.\n    - ``liburing`` must be included in both ``build-system.requires`` and ``project.dependencies`` in ``pyproject.toml`` to compile and use properly.\n    - Check out `Shakti`_ to see how to include ``liburing`` using ``cython``.\n\n\nTODO\n----\n    - Stable Release (currently still in alpha)\n    - Linux 6.1 Backwards compatibility.\n\n\nLicense\n-------\nFree, Public Domain (CC0). `Read more`_\n\n.. _pip: https://pip.pypa.io/en/stable/getting-started/\n.. _Read more: https://github.com/YoSTEALTH/Liburing/blob/master/LICENSE.txt\n.. _C Liburing: https://github.com/axboe/liburing\n.. _Lord of the io_uring: https://unixism.net/loti/\n.. _Shakti: https://github.com/YoSTEALTH/Shakti\n.. |test-status| image:: https://github.com/YoSTEALTH/Liburing/actions/workflows/test.yml/badge.svg?branch=master\n    :target: https://github.com/YoSTEALTH/Liburing/actions/workflows/test.yml\n    :alt: Test status\n.. |downloads| image:: https://img.shields.io/pypi/dm/liburing\n   :alt: PyPI - Downloads\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYoSTEALTH%2FLiburing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYoSTEALTH%2FLiburing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYoSTEALTH%2FLiburing/lists"}