Skip to main content

AIOFile

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

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 implementaion based on aio.h (with Cython).

  • For non-POSIX systems using thread-based implementation

Code examples

All code examples requires python 3.5+.

Write and Read

import asyncio
from aiofile import AIOFile, Reader, Writer


async def main():
    async with AIOFile("/tmp/hello.txt", 'w+') as afp:
        await afp.write("Hello ")
        await afp.write("world", offset=7)
        await afp.fsync()

        print(await afp.read())


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

Write and read with helpers

import asyncio
from aiofile import AIOFile, Reader, Writer


async def main():
    async with AIOFile("/tmp/hello.txt", 'w+') as afp
        writer = Writer(afp)
        reader = Reader(afp, chunk_size=8)

        await writer("Hello")
        await writer(" ")
        await writer("World")
        await afp.flush()

        async for chunk in reader:
            print(chunk)


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

Read file line by line

import asyncio
from aiofile import AIOFile, LineReader, Writer


async def main():
    async with AIOFile("/tmp/hello.txt", 'w+') as afp
        writer = Writer(afp)

        await writer("Hello")
        await writer(" ")
        await writer("World")
        await writer("\n")
        await writer("\n")
        await writer("From async world")
        await afp.flush()

        async for line in LineReader(afp):
            print(line)


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

Metadata

Release files for aiofile 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiofile 1.2.2
File Size Uploaded
aiofile-1.2.2.tar.gz 75.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for aiofile 1.2.2
File
aiofile-1.2.2-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.2.2-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
aiofile-1.2.2-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.2.2-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
aiofile-1.2.2-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.2.2-cp34-cp34m-macosx_10_6_intel.whl CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 924.8 kB

Release files / aiofile-1.2.2.tar.gz

Download URL aiofile-1.2.2.tar.gz
Size 75.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7574ff08fc7f0dfb1bbea737fb042368fb269b0ef7cd9a390d512073cfd1e74f
BLAKE2b-256 checksum
How to use checksums
de9a57924bb5f8266dfb206b29d5e0227eb542e89a5ba9207d6e1c52f8b02f9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiofile-1.2.2-cp36-cp36m-manylinux1_x86_64.whl

Download URL aiofile-1.2.2-cp36-cp36m-manylinux1_x86_64.whl
Size 183.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
8f86b5c758832c5433103a555b7094283613f73010fbe7bd24f0b9d1ce24ef2e
BLAKE2b-256 checksum
How to use checksums
62451268d1acff7310b9f6b89fdd79a986e438d8fa836b2f55d4f1188896cb87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiofile-1.2.2-cp36-cp36m-macosx_10_6_intel.whl

Download URL aiofile-1.2.2-cp36-cp36m-macosx_10_6_intel.whl
Size 97.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
3e59a9be9ced616f104e93a4f6d37228513ab75e9518342600d4bd536af77385
BLAKE2b-256 checksum
How to use checksums
6d6835e4963b64b8e20fce5e716846fba7f1f164947526f0270aef14d62e39ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiofile-1.2.2-cp35-cp35m-manylinux1_x86_64.whl

Download URL aiofile-1.2.2-cp35-cp35m-manylinux1_x86_64.whl
Size 184.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
70e39a88789c398b54525da826aaaba8f8451ec35a657f400391856f9075dbfc
BLAKE2b-256 checksum
How to use checksums
33333c963bb769490a11ad3b2c90599080813981591c19e92a16f7713d91d733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiofile-1.2.2-cp35-cp35m-macosx_10_6_intel.whl

Download URL aiofile-1.2.2-cp35-cp35m-macosx_10_6_intel.whl
Size 96.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
514b242d91c1c23a67943e025462a67803e851e90436fd5496ab607f5e706960
BLAKE2b-256 checksum
How to use checksums
1555ad6c2fd54204305f2799cd1441a2080303c35ead526f83cf478c553f4b17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiofile-1.2.2-cp34-cp34m-manylinux1_x86_64.whl

Download URL aiofile-1.2.2-cp34-cp34m-manylinux1_x86_64.whl
Size 189.7 kB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
521636e6952d0174518493cad3dbaebeb4016e658669e11b2a81fa6384205ad0
BLAKE2b-256 checksum
How to use checksums
f0dd906e53fcb8de777c95f1a5ac5fe19b05df8f2a74e8b58607180e4b55fc05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiofile-1.2.2-cp34-cp34m-macosx_10_6_intel.whl

Download URL aiofile-1.2.2-cp34-cp34m-macosx_10_6_intel.whl
Size 97.0 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
ae5d810c09c087cc91c182e3337993ee6ad1de593bfc356cd906985100bb6035
BLAKE2b-256 checksum
How to use checksums
7cc618b29e2da40f0029be0665b99013967a44d6f3c60c9c69b61eb7e18cf97e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.11.1

2 release files

3.11.0

2 release files

3.10.2

2 release files

3.10.1

2 release files

3.10.0

2 release files

3.9.0

2 release files

3.8.8

2 release files

3.8.7

2 release files

3.8.6

2 release files

3.8.5

2 release files

3.8.4

2 release files

3.8.3

2 release files

3.8.2

1 release file

3.8.1

1 release file

3.8.0

1 release file

3.7.4

2 release files

3.7.3

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.1

1 release file

3.5.0

2 release files

3.4.0

2 release files

3.3.3

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.5.2

7 release files

1.5.1

8 release files

1.4.3

8 release files

1.4.2

7 release files

1.4.0

8 release files

1.3.0

7 release files

1.2.6

7 release files

1.2.5

7 release files

This release

1.2.2 This release

7 release files

1.2.1

7 release files

1.2.0

7 release files

0.5.3

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page