Skip to main content

Context manager to raise an exception when a future is done

Project description

async_interrupt

CI Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License

Interrupt context manager for asyncio.

This module provides a context manager that can be used to interrupt a block of code as soon as possible when a future is done.

The purpose is to raise as soon as possible to avoid any race conditions.

This is based loosely on async_timeout by Andrew Svetlov and cpython asyncio.timeout

Usage

async with interrupt(future, ValueError, "message"):
    future.set_result(None)
    await asyncio.sleep(0)

Installation

Install this via pip (or your favourite package manager):

pip install async_interrupt

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This package was created with Copier and the browniebroke/pypackage-template project template.

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_interrupt-1.2.2.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_interrupt-1.2.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file async_interrupt-1.2.2.tar.gz.

File metadata

  • Download URL: async_interrupt-1.2.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for async_interrupt-1.2.2.tar.gz
Algorithm Hash digest
SHA256 be4331a029b8625777905376a6dc1370984c8c810f30b79703f3ee039d262bf7
MD5 e4b399bd7b06522130a832302e7facc2
BLAKE2b-256 5679732a581e3ceb09f938d33ad8ab3419856181d95bb621aa2441a10f281e10

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_interrupt-1.2.2.tar.gz:

Publisher: ci.yml on Bluetooth-Devices/async_interrupt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file async_interrupt-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for async_interrupt-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8deb884acfb5fe55188a693ae8a4381bbbd2cb6e670dac83869489513eec2c
MD5 d39b60fb0503b4d33b852959c48a79d9
BLAKE2b-256 5a77060b972fa7819fa9eea9a70acf8c7c0c58341a1e300ee5ccb063e757a4a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for async_interrupt-1.2.2-py3-none-any.whl:

Publisher: ci.yml on Bluetooth-Devices/async_interrupt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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