Async version of tempfile
Project description
asynctempfile
Async interface for the standard tempfile module. Implements the following 4 classes:
- TemporaryFile
- NamedTemporaryFile
- SpooledTemporaryFile
- TemporaryDirectory
Blocking methods are delegated to threadpools using loop.run_in_executor(). Non-blocking methods and properties retain a sync interface. SpooledTemporaryFile only delegates if the in-memory stream is rolled to disk. New instances of the above classes return wrapped with a context manager allowing use with async with and async for.
Credit
An extension of github.com/Tinche/aiofiles
Examples
import asynctempfile
async with asynctempfile.TemporaryFile('wb+') as f:
await f.write(b'Hello, World!')
import asynctempfile
async with asynctempfile.NamedTemporaryFile('wb+') as f:
await f.write(b'Line1\n Line2')
await f.seek(0)
async for line in f:
print(line)
Dependencies
aiofiles
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 Distribution
Close
Hashes for asynctempfile-0.3.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd7369d9c3c1d35e663932cc42f5374f0e76fba60155f9fdd444aa5c556e9f4d |
|
MD5 | 8d56b336466b063448bfd7ef12f814c6 |
|
BLAKE2b-256 | 3add0603de919e23d9b9fd122700a98eb7aed2fdff9b35e755aa54f7c03be121 |