GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing pypi.org — aiofiles aiofiles 25.1.0File support for asyncio. pip install aiofiles aiofiles: file support for asyncioaiofiles is an Apache2 licensed library, written in Python, for handling local disk files in asyncio applications. Ordinary local file IO is blocking, and cannot easily and portably be made asynchronous. This means doing file IO may interfere with asyncio applications, which shouldn't block the executing thread. aiofiles helps with this by introducing asynchronous versions of files that support delegating operations to a separate thread pool. async with aiofiles.open('filename', mode='r') as f:
contents = await f.read()
print(contents)
'My file contents'
Asynchronous iteration is also supported. async with aiofiles.open('filename') as f:
async for line in f:
...
Asynchronous interface to tempfile module. async with aiofiles.tempfile.TemporaryFile('wb') as f:
await f.write(b'Hello, World!')
Features
InstallationTo install aiofiles, simply: pip install aiofiles
UsageFiles are opened using the In case of success, an asynchronous file object is returned with an API identical to an ordinary file, except the following methods are coroutines and delegate to an executor:
In case of failure, one of the usual exceptions will be raised.
The
Tempfileaiofiles.tempfile implements the following interfaces:
Results return wrapped with a context manager allowing use with async with and async for. async with aiofiles.tempfile.NamedTemporaryFile('wb+') as f:
await f.write(b'Line1\n Line2')
await f.seek(0)
async for line in f:
print(line)
async with aiofiles.tempfile.TemporaryDirectory() as d:
filename = os.path.join(d, "file.ext")
Writing tests for aiofilesReal file IO can be mocked by patching aiofiles.threadpool.wrap.register(mock.MagicMock)(
lambda *args, **kwargs: aiofiles.threadpool.AsyncBufferedIOBase(*args, **kwargs)
)
async def test_stuff():
write_data = 'data'
read_file_chunks = [
b'file chunks 1',
b'file chunks 2',
b'file chunks 3',
b'',
]
file_chunks_iter = iter(read_file_chunks)
mock_file_stream = mock.MagicMock(
read=lambda *args, **kwargs: next(file_chunks_iter)
)
with mock.patch('aiofiles.threadpool.sync_open', return_value=mock_file_stream) as mock_open:
async with aiofiles.open('filename', 'w') as f:
await f.write(write_data)
assert await f.read() == b'file chunks 1'
mock_file_stream.write.assert_called_once_with(write_data)
ContributingContributions are very welcome. Tests can be run with Project linksData verified by PyPI on Oct 9, 2025
Data provided by the project maintainers, verified at the time the release was uploaded to PyPI.
Key datesPyPI dataData sourced directly from PyPI's database.
1 maintainerPyPI dataData sourced directly from PyPI's database.
CreditsData verified by PyPI on Oct 9, 2025Data provided by the project maintainers, verified at the time the release was uploaded to PyPI. Confirms that the provided email matches a verified, public email address on a PyPI user account associated with the project.
Author: Tin Tvrtkovic GitHub StatisticsData verified by PyPI on Oct 9, 2025The GitHub source repository was provided by the project maintainers and verified by PyPI at the time of upload. Stars, forks, and open issues/PRs are derived from that repository and have not been independently verified.
ProvenanceData verified by PyPI on Oct 9, 2025Data provided by the project maintainers and verified by PyPI at the time of upload.
LicenseApache Software License (Apache-2.0) RequiresPython >=3.9 Classifiers
MetadataProject linksData verified by PyPI on Oct 9, 2025
Data provided by the project maintainers, verified at the time the release was uploaded to PyPI.
Key datesPyPI dataData sourced directly from PyPI's database.
1 maintainerPyPI dataData sourced directly from PyPI's database.
CreditsData verified by PyPI on Oct 9, 2025Data provided by the project maintainers, verified at the time the release was uploaded to PyPI. Confirms that the provided email matches a verified, public email address on a PyPI user account associated with the project.
Author: Tin Tvrtkovic GitHub StatisticsData verified by PyPI on Oct 9, 2025The GitHub source repository was provided by the project maintainers and verified by PyPI at the time of upload. Stars, forks, and open issues/PRs are derived from that repository and have not been independently verified.
ProvenanceData verified by PyPI on Oct 9, 2025Data provided by the project maintainers and verified by PyPI at the time of upload.
LicenseApache Software License (Apache-2.0) RequiresPython >=3.9 Classifiers
Release files for aiofiles 25.1.0For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation. Source distribution (sdist)
Built distribution (wheel)
Total release size: 61.0 kB Release files / aiofiles-25.1.0.tar.gz
ProvenanceProvenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats. PyPI Publish AttestationPyPI verified that this artifact, at this checksum, originated from the publisher listed below. Signed by GitHub Actions, verified by PyPI on Oct 9, 2025. Transparency logIdentity
WorkflowArtifact
Release files / aiofiles-25.1.0-py3-none-any.whl
ProvenanceProvenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats. PyPI Publish AttestationPyPI verified that this artifact, at this checksum, originated from the publisher listed below. Signed by GitHub Actions, verified by PyPI on Oct 9, 2025. Transparency logIdentity
WorkflowArtifact
Security for aiofiles 25.1.0ProvenanceProvenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats. Full provenanceBoth files in this release have been uploaded with provenance metadata.
Select from 2 files
No files match the current filters. Reset filters
Attestation for aiofiles-25.1.0.tar.gzPyPI Publish AttestationPyPI verified that this artifact, at this checksum, originated from the publisher listed below. Signed by GitHub Actions, verified by PyPI on Oct 9, 2025. Transparency logIdentity
WorkflowArtifact
Attestation for aiofiles-25.1.0-py3-none-any.whlPyPI Publish AttestationPyPI verified that this artifact, at this checksum, originated from the publisher listed below. Signed by GitHub Actions, verified by PyPI on Oct 9, 2025. Transparency logIdentity
WorkflowArtifact
A note on package securityPyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package. To learn more about protecting yourself from malicious actors, visit our package security documentation. Release history Release notifications | RSS feed | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |