awesome-asyncio
awesome-asyncio copied to clipboard
Add async_property
What is this project?
You can use @async_property just as you would with @property, but on an async function.
class Foo:
@async_property
async def remote_value(self):
return await get_remote_value()
The property remote_value now returns an awaitable coroutine.
instance = Foo()
await instance.remote_value
Why is it awesome?
- Both regular and cached property.
- Cached properties can be accessed multiple times without repeating function.
- Cus duh!
Forgot the link: https://github.com/ryananguiano/async_property
Ready for merge