Asynchronous module import for asyncio
Project description
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
Project details
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
File details
Details for the file aioimport-0.1.5.tar.gz
.
File metadata
- Download URL: aioimport-0.1.5.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eb26f5a0d37545ad5ec803d5bf55d386964a61a0dfdf212a4e784e24b934e54 |
|
MD5 | 1298a9147ab7726e688083a1e75acf12 |
|
BLAKE2b-256 | ca2751f576a70873310a7fa307a6caf7b26e6a25e85f12b4bd09a22f31c98f30 |
File details
Details for the file aioimport-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: aioimport-0.1.5-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39add0230e265123d0d674f2d694b2463d13c0ced182b0a1927e1662ddf88b9d |
|
MD5 | a98450cfc7e245510569a6eb0db526b3 |
|
BLAKE2b-256 | 5345fffa0f2c3cfeba283ad1026060f4a894f46b9586c39e709987deac66e9fd |