Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hellysmile/async_armor
Graceful drop-in replacement for asyncio.shield
https://github.com/hellysmile/async_armor
asyncio graceful shield
Last synced: 29 days ago
JSON representation
Graceful drop-in replacement for asyncio.shield
- Host: GitHub
- URL: https://github.com/hellysmile/async_armor
- Owner: hellysmile
- License: mit
- Created: 2017-05-11T21:07:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-21T18:57:56.000Z (almost 3 years ago)
- Last Synced: 2024-11-10T22:24:30.412Z (2 months ago)
- Topics: asyncio, graceful, shield
- Language: Python
- Homepage: https://pypi.python.org/pypi/async_armor
- Size: 15.6 KB
- Stars: 15
- Watchers: 21
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
async_armor
===========:info: Graceful drop-in replacement for asyncio.shield
.. image:: https://img.shields.io/travis/wikibusiness/async_armor.svg
:target: https://travis-ci.org/wikibusiness/async_armor.. image:: https://img.shields.io/pypi/v/async_armor.svg
:target: https://pypi.python.org/pypi/async_armorInstallation
------------.. code-block:: shell
pip install async_armor
Usage
-----.. code-block:: python
import asyncio
from async_armor import armor
calls = 0
async def call_shield():
global calls
await asyncio.sleep(1)
calls += 1@armor
async def call_deco():
global calls
await asyncio.sleep(1)
calls += 1async def main():
task = armor(call_shield())
task.cancel()task = asyncio.ensure_future(call_deco())
task.cancel()loop = asyncio.get_event_loop()
loop.run_until_complete(main())
armor.close()
loop.run_until_complete(armor.wait_closed())assert calls == 2
loop.close()
Python 3.3+ is required