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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: anyioutils-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for anyioutils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 471287921b76aa239bd84ef0e92c16b7743fa1fa03495bef9025f6d054177667
MD5 1ba0376c45e7159e38b28c90559a537c
BLAKE2b-256 387259a0d3c76e2e0d6d377487e456314be89f50b1ec77e687537068652e60a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: anyioutils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for anyioutils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3620128c9834c8b00281a4efb16bf2db85f4f08d24e61f6810035a8c86071e80
MD5 75c8eceb9b9e7eb9f4c1f30f8681f43c
BLAKE2b-256 0379733fc769e93af87cd3b15e0aafe61bad7db176e2e7d574307e5ea9237ff4

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