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
aiofile-1.3.0.tar.gz
(75.6 kB
view details)
Built Distributions
File details
Details for the file aiofile-1.3.0.tar.gz
.
File metadata
- Download URL: aiofile-1.3.0.tar.gz
- Upload date:
- Size: 75.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88a57a8f47560516f2025429bd62dbaeb141b1285cead4276bfaa3269cd85079 |
|
MD5 | 0431d2cc692723d56dd327c2a7c2a731 |
|
BLAKE2b-256 | 3536c31f828248c54fea73ddd265063ecf527463d78ed627e23c9afcca56ee71 |
File details
Details for the file aiofile-1.3.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiofile-1.3.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 184.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4ea892a2bbdc5495bbfb35a26735448561b319b6cba127fcae2adc92ef17ea4 |
|
MD5 | aa98607e4ec26d0f9a17e8e9a0468e9d |
|
BLAKE2b-256 | abe9579ae3abc8e798b4aa9cd7b582e27f7d2e51261b83129643a1d4cbfddcbf |
File details
Details for the file aiofile-1.3.0-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: aiofile-1.3.0-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 98.2 kB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c09eedf16d3d993823ecac3578b09c2c5610f07866ae0af026f289157e0f9700 |
|
MD5 | d0a2b02dafbc7f8e1431431b122b7f21 |
|
BLAKE2b-256 | 546cbf81c0bfe70d2d8f4f965ec4f6a4d411a9b58fd573132bd6fb6181f2303f |
File details
Details for the file aiofile-1.3.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiofile-1.3.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 184.8 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a4e51e77f58f17c8642583ebcb9f0b5fa5709e844d2cf2255f003ae802aba38 |
|
MD5 | a51cb726cff6655a0a801fa1510f3af9 |
|
BLAKE2b-256 | 8a28b220029ae3f786f68ce11bb35b7dc0da4abd49a8074a9d26392fc3ec3b9a |
File details
Details for the file aiofile-1.3.0-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: aiofile-1.3.0-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 97.0 kB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65f00f0da4679d96217980029b3d06da216915483fc19d48d77319838777fa10 |
|
MD5 | be60b97c091ad8edd73d6851f2b70923 |
|
BLAKE2b-256 | c3cce0511b844e03b498b87032ad5d7ba152525dfe594a7fac9a170ee7c53463 |
File details
Details for the file aiofile-1.3.0-cp34-cp34m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiofile-1.3.0-cp34-cp34m-manylinux1_x86_64.whl
- Upload date:
- Size: 190.0 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaa8f3612e1f3084ec8627ff16a1ddfe3b090aa34c1ce523ba7b7e3fb26a0c7f |
|
MD5 | 4b2f3de4eaa83fb62848aecb7a377bab |
|
BLAKE2b-256 | 27933c0bdc0544270bcbd2937ce3fa14d5edb05845f3d47ee6d2492819b212ab |
File details
Details for the file aiofile-1.3.0-cp34-cp34m-macosx_10_6_intel.whl
.
File metadata
- Download URL: aiofile-1.3.0-cp34-cp34m-macosx_10_6_intel.whl
- Upload date:
- Size: 97.3 kB
- Tags: CPython 3.4m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3316a454d9799febd003a5a5b3d8e7c26d16438833fa9b3d886bcf4bc9961d8 |
|
MD5 | 026791d8a2d56733b08992eb14933df7 |
|
BLAKE2b-256 | 7df177ca6a057bb526944b545097b0e896c70ab41969c1ec42455a8527f180fe |