Skip to main content
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.6

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.6
File Size Uploaded
aiofile-1.2.6.tar.gz 75.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for aiofile 1.2.6
File
aiofile-1.2.6-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.2.6-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.6-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.2.6-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.6-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.2.6-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: 925.5 kB

Release files / aiofile-1.2.6.tar.gz

Download URL aiofile-1.2.6.tar.gz
Size 75.4 kB
Tags Source
SHA-256 checksum
How to use checksums
40aa8f9bb2a31d547dc80898ae371d3a4376f5de69fc0b4634987d55c00c7849
BLAKE2b-256 checksum
How to use checksums
ba728ed2f375abfcd2306e2c09a81cc02da88da54d957afbdb226ef316aaf811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL aiofile-1.2.6-cp36-cp36m-manylinux1_x86_64.whl
Size 183.9 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
95ef9a09a15367b5e954db945a9b215ecc9561b1afa6fb02f2548f9b6149945e
BLAKE2b-256 checksum
How to use checksums
9912c81ad0d6b796d1b0a026f3b0d1cc7d3a933b7ab90660a0da54d5e1cbc318
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL aiofile-1.2.6-cp35-cp35m-manylinux1_x86_64.whl
Size 184.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
7c53a1d6ff569a1279090a05a3109ac960a8223ef7d017586ba62516fb36160e
BLAKE2b-256 checksum
How to use checksums
1838390950b846a4e408068d5c0bc6da041a5e2eee962410d16cfb8d11059e37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

Download URL aiofile-1.2.6-cp34-cp34m-macosx_10_6_intel.whl
Size 97.1 kB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
044132edad66df04f18fcb98d3dff50a7a4bb58c01ae73f82c3c16e158cce8ec
BLAKE2b-256 checksum
How to use checksums
067ba838a1dd43f7c03793257fb001296da407657dc26473d38b42c78415bf70
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

This release

1.2.6 This release

7 release files

1.2.5

7 release files

1.2.2

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