Graceful drop-in replacement for asyncio.shield
Project description
- info:
Graceful drop-in replacement for asyncio.shield
Installation
pip install async_armor
Usage
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 += 1
async def main():
task = armor(call_shield())
task.cancel()
task = asyncio.ensure_future(call_deco())
await asyncio.sleep(0)
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async_armor-0.0.1.tar.gz
(4.6 kB
view details)
File details
Details for the file async_armor-0.0.1.tar.gz
.
File metadata
- Download URL: async_armor-0.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 331ad00e1173a24cc96a3388c5a1507c8a6dc9af7567f795302ca1331a02b4dd |
|
MD5 | dcdf3466cf4ba37cc6c68045a23d7163 |
|
BLAKE2b-256 | d34a73b892e5397589efb1b43de0ba4eb1e6efb7b2ab1ba33f7f4080013a32be |