Skip to main content

Asynchronous file IO for Linux Posix and Windows.

Project description

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

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

Troubleshooting

The linux implementation works normal for modern linux kernel versions and file systems. So you may have problems specific for your environment. It’s not a bug and might be resolved some ways:

  1. Upgrade the kernel
  2. Use compatible file system
  3. Use threads based or pure python implementation.

The caio since version 0.7.0 contains some ways to do this.

1. In runtime use the environment variable CAIO_IMPL with possible values:

  • linux - use native linux kernels aio mechanism
  • thread - use thread based implementation written in C
  • python - use pure python implementation

2. File default_implementation located near __init__.py in caio installation path. It’s useful for distros package maintainers. This file might contains comments (lines starts with # symbol) and the first line should be one of linux thread or python.

Previous versions allows direct import of the target implementation.

Project details


Download files

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

Files for caio, version 0.8.0
Filename, size File type Python version Upload date Hashes
Filename, size caio-0.8.0-cp35-cp35m-manylinux2010_x86_64.whl (80.9 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size caio-0.8.0-cp36-cp36m-macosx_10_9_x86_64.whl (33.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size caio-0.8.0-cp36-cp36m-manylinux2010_x86_64.whl (81.3 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size caio-0.8.0-cp37-cp37m-macosx_10_9_x86_64.whl (33.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size caio-0.8.0-cp37-cp37m-manylinux2010_x86_64.whl (83.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size caio-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl (43.4 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size caio-0.8.0-cp38-cp38-manylinux2010_x86_64.whl (105.4 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size caio-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl (33.5 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size caio-0.8.0-cp39-cp39-manylinux2010_x86_64.whl (82.6 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size caio-0.8.0.tar.gz (22.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page