Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Asynchronous file operations.

Project Description

Real asynchronous file operations with asyncio support.

Status

Development - BETA

Features

  • AIOFile has no internal pointer. You should pass offset and chunk_size for each operation or use helpers (Reader or Writer).
  • For POSIX (MacOS X and Linux) using Cython implementaion based on aio.h (using Cython).
  • For non-POSIX systems using thread-based implementation

Code examples

Totally async read and write:

import asyncio
from aiofile import AIOFile, Reader, Writer

async def main(loop):
    aio_file = AIOFile("/tmp/hello.txt", 'w+', loop=loop)

    await aio_file.write(b"Hello ")
    await aio_file.write(b"world", offset=7)
    await aio_file.fsync()

    print(await aio_file.read())

loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))

Write and read with helpers:

import asyncio
from aiofile import AIOFile, Reader, Writer

async def main(loop):
    aio_file = AIOFile("/tmp/hello.txt", 'w+', loop=loop)

    writer = Writer(aio_file)
    reader = Reader(aio_file, chunk_size=8)

    await writer(b"Hello")
    await writer(b" ")
    await writer(b"World")
    await aio_file.flush()

    async for chunk in reader:
        print(chunk)

loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
Release History

Release History

This version
History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.0

History Node

0.3.0

History Node

0.2.3

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
aiofile-0.5.2-cp34-cp34m-macosx_10_6_intel.whl (96.2 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Oct 8, 2017
aiofile-0.5.2-cp34-cp34m-manylinux1_x86_64.whl (190.4 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Oct 8, 2017
aiofile-0.5.2-cp35-cp35m-macosx_10_6_intel.whl (94.7 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Oct 8, 2017
aiofile-0.5.2-cp35-cp35m-manylinux1_x86_64.whl (184.6 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Oct 8, 2017
aiofile-0.5.2-cp36-cp36m-macosx_10_6_intel.whl (93.1 kB) Copy SHA256 Checksum SHA256 cp36 Wheel Oct 8, 2017
aiofile-0.5.2-cp36-cp36m-manylinux1_x86_64.whl (186.5 kB) Copy SHA256 Checksum SHA256 cp36 Wheel Oct 8, 2017
aiofile-0.5.2.tar.gz (71.7 kB) Copy SHA256 Checksum SHA256 Source Oct 8, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting