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.3.0

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.3.0
File Size Uploaded
aiofile-1.3.0.tar.gz 75.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for aiofile 1.3.0
File
aiofile-1.3.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.3.0-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
aiofile-1.3.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.3.0-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
aiofile-1.3.0-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.3.0-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: 927.0 kB

Release files / aiofile-1.3.0.tar.gz

Download URL aiofile-1.3.0.tar.gz
Size 75.6 kB
Tags Source
SHA-256 checksum
How to use checksums
88a57a8f47560516f2025429bd62dbaeb141b1285cead4276bfaa3269cd85079
BLAKE2b-256 checksum
How to use checksums
3536c31f828248c54fea73ddd265063ecf527463d78ed627e23c9afcca56ee71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

Download URL aiofile-1.3.0-cp35-cp35m-manylinux1_x86_64.whl
Size 184.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
3a4e51e77f58f17c8642583ebcb9f0b5fa5709e844d2cf2255f003ae802aba38
BLAKE2b-256 checksum
How to use checksums
8a28b220029ae3f786f68ce11bb35b7dc0da4abd49a8074a9d26392fc3ec3b9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

This release

1.3.0 This release

7 release files

1.2.6

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