معرفی شرکت ها


async-property-0.2.1


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Python decorator for async properties.
ویژگی مقدار
سیستم عامل -
نام فایل async-property-0.2.1
نام async-property
نسخه کتابخانه 0.2.1
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Ryan Anguiano
ایمیل نویسنده ryan.anguiano@gmail.com
آدرس صفحه اصلی https://github.com/ryananguiano/async_property
آدرس اینترنتی https://pypi.org/project/async-property/
مجوز MIT license
============== async_property ============== .. image:: https://img.shields.io/pypi/v/async_property.svg :target: https://pypi.org/project/async-property/ .. image:: https://img.shields.io/travis/ryananguiano/async_property.svg :target: https://travis-ci.org/ryananguiano/async_property .. image:: https://readthedocs.org/projects/async-property/badge/?version=latest :target: https://async-property.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://pyup.io/repos/github/ryananguiano/async_property/shield.svg :target: https://pyup.io/repos/github/ryananguiano/async_property/ :alt: Updates Python decorator for async properties. * Free software: MIT license * Documentation: https://async-property.readthedocs.io * Package: https://pypi.org/project/async-property * Source code: https://github.com/ryananguiano/async_property Install ------- To install async_property, run this command in your terminal: .. code-block:: console $ pip install async-property Or if you have pipenv: .. code-block:: console $ pipenv install async-property Usage ----- You can use ``@async_property`` just as you would with ``@property``, but on an async function. .. code-block:: python class Foo: @async_property async def remote_value(self): return await get_remote_value() The property ``remote_value`` now returns an awaitable coroutine. .. code-block:: python instance = Foo() await instance.remote_value Cached Properties ~~~~~~~~~~~~~~~~~ ``@async_cached_property`` will call the function only once. Subsequent awaits to the property will return a cached value. .. code-block:: python class Foo: @async_cached_property async def value(self): print('loading value') return 123 >>> instance = Foo() >>> instance.value <AwaitableOnly "Foo.value"> >>> await instance.value loading value 123 >>> await instance.value 123 >>> instance.value 123 >>> instance.value = 'abc' >>> instance.value 'abc' >>> await instance.value 'abc' >>> del instance.value >>> await instance.value loading value 123 AwaitLoader ~~~~~~~~~~~ If you have an object with multiple cached properties, you can subclass ``AwaitLoader``. This will make your class instances awaitable and will load all ``@async_cached_property`` fields concurrently. ``AwaitLoader`` will call ``await instance.load()``, if it exists, before loading properties. .. code-block:: python class Foo(AwaitLoader): async def load(self): print('load called') @async_cached_property async def db_lookup(self): return 'success' @async_cached_property async def api_call(self): return 'works every time' >>> instance = await Foo() load called >>> instance.db_lookup 'success' >>> instance.api_call 'works every time' Features -------- * Both regular and cached property. * ``@async_cached_property`` can be accessed multiple times without repeating function call. * ``@async_cached_property`` uses asyncio.Lock to ensure function is called only once per instance. * Full test coverage with py.test Credits ------- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. .. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage The ObjectProxy_ class was taken from wrapt_ library by Graham Dumpleton. .. _ObjectProxy: https://github.com/GrahamDumpleton/wrapt/blob/master/src/wrapt/wrappers.py .. _wrapt: https://github.com/GrahamDumpleton/wrapt ======= History ======= 0.2.1 (2019-04-13) ------------------ * Update docs and readme 0.2.0 (2019-04-12) ------------------ * Use instance state to hold cache and locks 0.1.4 (2019-04-12) ------------------ * Fix inheritance issues on AwaitLoader 0.1.3 (2019-04-12) ------------------ * Cleanup code 0.1.2 (2019-04-12) ------------------ * Fix asyncio.Lock issues 0.1.1 (2019-04-11) ------------------ * Complete test coverage and update readme 0.1.0 (2019-04-11) ------------------ * First release on PyPI.


نحوه نصب


نصب پکیج whl async-property-0.2.1:

    pip install async-property-0.2.1.whl


نصب پکیج tar.gz async-property-0.2.1:

    pip install async-property-0.2.1.tar.gz