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.4.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.4.0
File Size Uploaded
aiofile-1.4.0.tar.gz 75.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for aiofile 1.4.0
File
aiofile-1.4.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.4.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.4.0-cp36-cp36m-linux_armv7l.whl CPython 3.6 CPython 3.6 pymalloc linux armv7l Details
aiofile-1.4.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.4.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.4.0-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
aiofile-1.4.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: 1.1 MB

Release files / aiofile-1.4.0.tar.gz

Download URL aiofile-1.4.0.tar.gz
Size 75.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cd8642420821f8a0bb96388d804167e7b1df3dd1d580a5054aac77d7240f0574
BLAKE2b-256 checksum
How to use checksums
4dc4e599afd81991aeb597545dec91ceda6c38cd9ac5d0d81f476df5fcb640ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

Release files / aiofile-1.4.0-cp36-cp36m-linux_armv7l.whl

Download URL aiofile-1.4.0-cp36-cp36m-linux_armv7l.whl
Size 169.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc linux armv7l
SHA-256 checksum
How to use checksums
757e07cbfacb74c530e69523794f7512ac82c5b8819dc49fc599270ff7183df7
BLAKE2b-256 checksum
How to use checksums
6aedcee3fe3ccbe0d05af6723085e024a9af70c2a522f3298b71e84eb2f3b8eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL aiofile-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
Size 182.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2ebacb4d0cf1fd025d016b36e8d92190eb785b9fd5ba1273adb14e1d903bad27
BLAKE2b-256 checksum
How to use checksums
d430a88e86a42be0f1574aa9534e433756db86109775233175fd30fbd833431c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

This release

1.4.0 This release

8 release files

1.3.0

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