Skip to main content

Asynchronous file IO for Linux Posix and Windows.

Project description

Python bindings for Linux AIO API and simple asyncio wrapper.

Example

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caio-0.5.6.tar.gz (16.6 kB view hashes)

Uploaded Source

Built Distributions

caio-0.5.6-cp38-cp38-manylinux2010_x86_64.whl (106.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

caio-0.5.6-cp38-cp38-macosx_10_9_x86_64.whl (42.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

caio-0.5.6-cp37-cp37m-manylinux2010_x86_64.whl (81.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

caio-0.5.6-cp37-cp37m-macosx_10_9_x86_64.whl (32.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

caio-0.5.6-cp36-cp36m-manylinux2010_x86_64.whl (80.1 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

caio-0.5.6-cp36-cp36m-macosx_10_9_x86_64.whl (32.2 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

caio-0.5.6-cp35-cp35m-manylinux2010_x86_64.whl (79.7 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

caio-0.5.6-cp35-cp35m-macosx_10_6_intel.whl (37.8 kB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page