Metadata-Version: 2.1
Name: caio
Version: 0.6.3
Summary: Asynchronous file IO for Linux Posix and Windows.
Home-page: UNKNOWN
Author: Dmitry Orlov <me@mosquito.su>
Author-email: me@mosquito.su
License: Apache Software License
Project-URL: Documentation, https://github.com/mosquito/caio/
Project-URL: Source, https://github.com/mosquito/caio
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.5.*, <4
Provides-Extra: develop
License-File: LICENSE

Python wrapper for AIO
======================

.. warning:: ``fsync``/``fdsync`` operations in Linux aio implementation supports since 4.18. related calls will have no effect.

Python bindings for Linux AIO API and simple asyncio wrapper.

Example
-------

.. code-block:: python

    import asyncio
    from caio import AsyncioContext

    loop = asyncio.get_event_loop()

    async def main():
        # max_requests=128 by default
        ctx = AsyncioContext(max_requests=128)

        with open("test.file", "wb+") as fp:
            fd = fp.fileno()

            # Execute one write operation
            await ctx.write(b"Hello world", fd, offset=0)

            # Execute one read operation
            print(await ctx.read(32, fd, offset=0))

            # Execute one fdsync operation
            await ctx.fdsync(fd)

            op1 = ctx.write(b"Hello from ", fd, offset=0)
            op2 = ctx.write(b"async world", fd, offset=11)

            await asyncio.gather(op1, op2)

            print(await ctx.read(32, fd, offset=0))
            # Hello from async world


    loop.run_until_complete(main())


