Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.
/ pyasyncinit Public archive

Python class decorator to enable async `__init__`

License

Notifications You must be signed in to change notification settings

kchmck/pyasyncinit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asyncinit -- Enable async __init__

Documentation

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

About

Python class decorator to enable async `__init__`

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages