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.2.tar.gz
(2.2 kB
view hashes)
Built Distribution
Close
Hashes for asyncinit-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e82addb3911e2243271a34f31944f1a7ca5ffeff59420587983cebe05f0dd19 |
|
MD5 | a379ac77a820c1c8c7b4b12cdc859ef7 |
|
BLAKE2b-256 | 5d70d83b8ffaf97bfd425a52e838dd3ff053e7f1e3c9f810d6f98aff29d8f943 |