Skip to main content

Graceful drop-in replacement for asyncio.shield

Project description

info:

Graceful drop-in replacement for asyncio.shield

https://img.shields.io/travis/wikibusiness/async_armor.svg https://img.shields.io/pypi/v/async_armor.svg

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())
    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


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.2.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file async_armor-0.0.2.tar.gz.

File metadata

  • Download URL: async_armor-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for async_armor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 db45d2646ecd98508b93853c8cb9d385274035ce15d77c76c6509b6750f9b829
MD5 d2b19ebd092d6ce2c0e3ab74490d029a
BLAKE2b-256 74446f423606a4c08b6def59aef74073209669ba011de040fa0932be1fb85c7e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page