Class decorator to enable async __init__
Project description
asyncinit -- Enable async __init__
This package provides the asyncinit
decorator, which enables an asynchronous constructor
to be called like any other asynchronous function.
Example
from asyncinit import asyncinit
@asyncinit
class MyClass:
async def __init__(self, param):
self.val = await self.deferredFn(param)
async def deferredFn(self, x):
# ...
return x + 2
obj = await MyClass(42)
assert obj.val == 44
Installation
This package requires Python >= 3.5.0 and can be installed with pip
:
pip install asyncinit
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
asyncinit-0.2.3.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for asyncinit-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9ca71891a8ae9d9a6efd7070fc1d1f8afa7b38fd873a47f351ea7c9092583d8 |
|
MD5 | a8aa45c4577756788c18691227d8ba70 |
|
BLAKE2b-256 | dfacc9bc8619f35ce7e6f062dde759bc8301344d13ed72c1a81b19a336159d84 |