Asynchronous file operations.
Project description
Real asynchronous file operations with asyncio support.
Status
Development - Stable
Features
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file aiofile-1.4.0.tar.gz
.
File metadata
- Download URL: aiofile-1.4.0.tar.gz
- Upload date:
- Size: 75.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd8642420821f8a0bb96388d804167e7b1df3dd1d580a5054aac77d7240f0574 |
|
MD5 | 9156da9f4ee18838a8bb1337df030d3e |
|
BLAKE2b-256 | 4dc4e599afd81991aeb597545dec91ceda6c38cd9ac5d0d81f476df5fcb640ec |
File details
Details for the file aiofile-1.4.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 180.5 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8401130bf9c2683a53ab63e892644e9baefea7fd945175694c1e2d0cc209a729 |
|
MD5 | 9c3971521bd955497a0e49f311b4f777 |
|
BLAKE2b-256 | a884b0bd63f86880b10196bde02807994385c502cf46c42e54334453cbefa66e |
File details
Details for the file aiofile-1.4.0-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 96.4 kB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f8f4309a77802eb812469cd656b05c38be6d44a919f9f9491cf1052fd33497a |
|
MD5 | 2dcd3f830bf3fe57c09cf6fa3aad395f |
|
BLAKE2b-256 | bbbfbf6ce9ac4201acb56b085bfb96e32f4056c6333f16a1bc9a17a16ecc7a01 |
File details
Details for the file aiofile-1.4.0-cp36-cp36m-linux_armv7l.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp36-cp36m-linux_armv7l.whl
- Upload date:
- Size: 169.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 757e07cbfacb74c530e69523794f7512ac82c5b8819dc49fc599270ff7183df7 |
|
MD5 | 31a888611c3505457d7021ccf8119a25 |
|
BLAKE2b-256 | 6aedcee3fe3ccbe0d05af6723085e024a9af70c2a522f3298b71e84eb2f3b8eb |
File details
Details for the file aiofile-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 182.4 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ebacb4d0cf1fd025d016b36e8d92190eb785b9fd5ba1273adb14e1d903bad27 |
|
MD5 | 01039addd4542134094ebf26ac9f2e34 |
|
BLAKE2b-256 | d430a88e86a42be0f1574aa9534e433756db86109775233175fd30fbd833431c |
File details
Details for the file aiofile-1.4.0-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 95.4 kB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54b49528af0747dbbcb586386fbb39a17245f7423eacf59ff867a322bacb0992 |
|
MD5 | c11348ec529b78abc14152f0efdbe379 |
|
BLAKE2b-256 | 975495ae85fb308a5fb396cb242f49293a07ca3efc224b3b7d04fccccd1c0fb2 |
File details
Details for the file aiofile-1.4.0-cp34-cp34m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp34-cp34m-manylinux1_x86_64.whl
- Upload date:
- Size: 186.5 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d332e85a15eeb99013c45215e4dc45cb92c0b7ff0062737887e20b3ce6cc8f98 |
|
MD5 | 279fb033928b9be48814b01d2546cffc |
|
BLAKE2b-256 | 7379356c82a1c74cd33eac9221b6048989747f7c418a98fb771ce652c13e19cd |
File details
Details for the file aiofile-1.4.0-cp34-cp34m-macosx_10_6_intel.whl
.
File metadata
- Download URL: aiofile-1.4.0-cp34-cp34m-macosx_10_6_intel.whl
- Upload date:
- Size: 95.7 kB
- Tags: CPython 3.4m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 402350e24e23fd2cb970f6982d4cde983c63b9a411649fcc2528a94f814bc7e3 |
|
MD5 | 073dcc34c32b49f3cab238b7ce11e26c |
|
BLAKE2b-256 | 4f5faefbadb0c60eab2541c18c2dfa19dec3449fe7bce9b22a57870c25b80953 |