Skip to main content

Asynchronous file operations.

Project description

Travis CI Latest Version https://img.shields.io/pypi/wheel/aiofile.svg https://img.shields.io/pypi/pyversions/aiofile.svg https://img.shields.io/pypi/l/aiofile.svg

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

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

aiofile-0.5.3.tar.gz (72.2 kB view details)

Uploaded Source

Built Distributions

aiofile-0.5.3-cp36-cp36m-manylinux1_x86_64.whl (188.2 kB view details)

Uploaded CPython 3.6m

aiofile-0.5.3-cp36-cp36m-macosx_10_6_intel.whl (93.6 kB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

aiofile-0.5.3-cp35-cp35m-manylinux1_x86_64.whl (185.1 kB view details)

Uploaded CPython 3.5m

aiofile-0.5.3-cp35-cp35m-macosx_10_6_intel.whl (94.9 kB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

aiofile-0.5.3-cp34-cp34m-manylinux1_x86_64.whl (191.5 kB view details)

Uploaded CPython 3.4m

aiofile-0.5.3-cp34-cp34m-macosx_10_6_intel.whl (96.4 kB view details)

Uploaded CPython 3.4m macOS 10.6+ intel

File details

Details for the file aiofile-0.5.3.tar.gz.

File metadata

  • Download URL: aiofile-0.5.3.tar.gz
  • Upload date:
  • Size: 72.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiofile-0.5.3.tar.gz
Algorithm Hash digest
SHA256 2a37d2e5e42ec11803b31a8939077d39159a7863b48b43dffc4453962db3b61e
MD5 5a4be2682e0cc9fd1a93989ca7574d67
BLAKE2b-256 8e2ca2c8029c4f80eea2c20317321918abaab7744daf20622a52cd39512440e4

See more details on using hashes here.

File details

Details for the file aiofile-0.5.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for aiofile-0.5.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0e05e29374a4274606b9cf595012dfe31256705f5330574e9478d3426283aa75
MD5 3fa0497dda65227375fdc8476ec2a274
BLAKE2b-256 f5e1a0d1f500605f3d960f6505c3444a11f8f751242f2abbcfe4288ba6f3b409

See more details on using hashes here.

File details

Details for the file aiofile-0.5.3-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for aiofile-0.5.3-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 1bdbf3cd07249f8b5a5cb3d1346bbdce6817e70066b57618f6723f7ee8fd699a
MD5 5e6428458c3ed13cd61c5b68f9985fd2
BLAKE2b-256 c7e057f0347f4d6f227c5db12fee6aeb024d280bce9e4b50a8fbee8a515f8225

See more details on using hashes here.

File details

Details for the file aiofile-0.5.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for aiofile-0.5.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 285defdecd84305c62c67c7234449a2a03666b347e952cf5f1c6a532376fe266
MD5 fa9a5e65fde3fd46377c89de020750bd
BLAKE2b-256 4f7eb7f6c516402a6044a62d7a837b9573fc8d86da4891d7b31e6de3ab667cba

See more details on using hashes here.

File details

Details for the file aiofile-0.5.3-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for aiofile-0.5.3-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 163e64be51e38c3b3282da180c201205a4e734f9f8f8d7fe767887459cc64704
MD5 79ab4976c461187987068867b7e563b8
BLAKE2b-256 337dc5dd8b85467cee10f839cd6b926b23b8c2ff35945a0c12f92891af8ac97f

See more details on using hashes here.

File details

Details for the file aiofile-0.5.3-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for aiofile-0.5.3-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c48da5ef555347aa2f438c47310463906457a51a6c44b6ea547d62d07003988b
MD5 3a34698cb7a5208cee8e0d70cf5c8487
BLAKE2b-256 c9ce6793d0f19a8e64f684ec4eaf0943f0132c437a70c88325b3bbd393920cdc

See more details on using hashes here.

File details

Details for the file aiofile-0.5.3-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for aiofile-0.5.3-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 1e86f828437745ba403c9bf376b30d88c8e3f71eb0d115a159e8c12004204197
MD5 1dd636a3228d3b62f026ed2d10557c4b
BLAKE2b-256 b9d4b6e52290e21ba393be059bbb0daa4b6a89f852b44216b2d86af13a94d6ea

See more details on using hashes here.

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