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.4.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for asyncinit-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f11291943488abd15a1463dad98452e3bd6b39e8e6d45bc7cc008a09825b11e |
|
MD5 | 0be5cead4ef2a7b05f7c596cc02b8a40 |
|
BLAKE2b-256 | b412a73bd1bcba7f99738d1f644ed17b526f84e97aaabda301800435ca202570 |