aioimport
Asynchronous module import for asyncio
Getting Started
Installing
Install from PyPI using:
pip install aioimport
The problem
Some naughty modules have long running operations during import
Naive solution
First thing that comes to mind is make import local:
async def my_work() -> None:
import naughty # will block event loop
It reduces time your program takes to start (or library to import), but it is still blocking your event loop.
Usage
import aioimport
async def my_work() -> None:
await aioimport.import_module("naughty") # will asynchronously import module
import naughty # will be instantaneous since `naughty` is already in `sys.modules`
await aioimport.reload(naughty) # and you can asynchronously reload modules too
How it works
Module import is done in asyncio default executor.
Be aware of the fact that GIL still exists and technically import is done concurrently rather than in parallel with your code.
License
This project is licensed under the MIT License - see the LICENSE file for details
Release files for aioimport 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aioimport-0.1.5.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aioimport-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / aioimport-0.1.5.tar.gz
| Download URL | aioimport-0.1.5.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0eb26f5a0d37545ad5ec803d5bf55d386964a61a0dfdf212a4e784e24b934e54
|
|
BLAKE2b-256 checksum How to use checksums |
ca2751f576a70873310a7fa307a6caf7b26e6a25e85f12b4bd09a22f31c98f30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.1 Windows/10
|
Release files / aioimport-0.1.5-py3-none-any.whl
| Download URL | aioimport-0.1.5-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39add0230e265123d0d674f2d694b2463d13c0ced182b0a1927e1662ddf88b9d
|
|
BLAKE2b-256 checksum How to use checksums |
5345fffa0f2c3cfeba283ad1026060f4a894f46b9586c39e709987deac66e9fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.1 Windows/10
|