Skip to main content

Utility classes for AnyIO

Project description

anyioutils

anyioutils.Future behaves the same as asyncio.Future except that:

  • you cannot directly await an anyioutils.Future object, but through its .wait() method (unlike an asyncio.Future, but like an asyncio.Event).
  • cancelling an anyioutils.Future doesn't raise an anyio.get_cancelled_exc_class(), but an anyioutils.CancelledError.
from anyioutils import CancelledError, Future
from anyio import create_task_group, run

async def set_result(future):
    future.set_result("done")

async def cancel(future):
    future.cancel()

async def main():
    async with create_task_group() as tg:
        future0 = Future()
        tg.start_soon(set_result, future0)
        assert await future0.wait() == "done"

        future1 = Future()
        tg.start_soon(cancel, future1)
        try:
            await future1.wait()
        except CancelledError:
            assert future1.cancelled()

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

anyioutils-0.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

anyioutils-0.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file anyioutils-0.0.0.tar.gz.

File metadata

  • Download URL: anyioutils-0.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for anyioutils-0.0.0.tar.gz
Algorithm Hash digest
SHA256 aa8fd9e059fcffdb523f38de6c0fe7ecabcb3663f0fb6072495e8f33917e9fa7
MD5 26b86dc8efa5081970c5f09e2ba77e27
BLAKE2b-256 cac2a8304583ad29bd66bc8bb44c55f4a0a3824d03e5af8413bd89726c7f4b09

See more details on using hashes here.

File details

Details for the file anyioutils-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: anyioutils-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for anyioutils-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4bab0c1b03e1609cf80b4dccf8db72f3c02e4e740fb4b9fdbef4b22d5db2023a
MD5 ebe580efb8a0ef318411b005d7bc5ab8
BLAKE2b-256 deeb55751af7e9be391c8b1e2db35acfbdae313dd380adb8c0ee1944f29a3e96

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