Skip to main content

No project description provided

Project description

Extra Async

Utilities for Python Asynchronous programming

aenumerate

Asynchronous version of Python's "enumerate". Just pass an async-iterator where the iterator would be, and use it in an async-for.

usage:

import asyncio

from extraasync import aenumerate

async def paused_pulses(n, message="pulse", interval=0.1):
    for i in range(n):
        asyncio.sleep(interval)
        yield message

async def main():
    for index, message in aenumerate(paused_pulses(5)):
        print(index, message)

asyncio.run(main())

ExtraTaskGroup

An asyncio.TaskGroup subclass that won't cancel all tasks when any of them errors out.

The hardcoded behavior of asyncio.TaskGroup is that when any exception is raised in any of the taskgroup tasks, all sibling incomplete tasks get cancelled immediatelly.

With ExtraTaskGroup, all created tasks are run to completion, and any exceptions are bubbled up as ExceptionGroups on the host task.

import asyncio

from extraasync import ExtraTaskGroup

async def worker(n):
    await asyncio.sleep(n/10)
    if n % 3 == 0:
        raise RuntimeError()
    return n

async def main():
    try:
        async with ExtraTaskGroup() as tg:
            tasks = [tg.create_task(worker(i)) for i in range(10)]
    except *RuntimeError as exceptions:
        print(exceptions)

asyncio.run(main())

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

extraasync-0.2.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

extraasync-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file extraasync-0.2.0.tar.gz.

File metadata

  • Download URL: extraasync-0.2.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for extraasync-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4aaeaa8db55b9c75c411111fc1f9d6c326f65efb9d2b04282faaad97874cdf66
MD5 dea0071d6e6ad53a73591b85e699e559
BLAKE2b-256 af117aef6de765c5a5ecc80eb2e6f0c4b57eb7090621f683b3a323b577c9f9fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for extraasync-0.2.0.tar.gz:

Publisher: pypi.yml on jsbueno/extraasync

Attestations:

File details

Details for the file extraasync-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: extraasync-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for extraasync-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 838618f34fd7c406eacb22e717c8071d2be8a8432f3270b244fa633fb7f12311
MD5 49bda39fa61a581cc419dec328ee1825
BLAKE2b-256 6a0595faf6dbbf3d97f9303619bf8a97a252a59c51f67a1716ac1cb0a369a995

See more details on using hashes here.

Provenance

The following attestation bundles were made for extraasync-0.2.0-py3-none-any.whl:

Publisher: pypi.yml on jsbueno/extraasync

Attestations:

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