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.4.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6417e84f0bcf677660b928065a19903e473dfa90cb87694e78c7c30eb8098b1c |
|
MD5 | e4b02f7225ab2682652b6ed8da6869b6 |
|
BLAKE2b-256 | 52e17a41ddb6dedb63ec8e0f6ea181399423af84edc7981c0409a8d6e2f73af6 |