$npx skillfedfor your agent

wait-for2

Asyncio wait_for that can handle simultaneous cancellation and future completion.

With conditionsPyPI Software DevelopmentReleased Jun 2025330.7K downloads / moApache-2.0Pure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — wait_for2-0.4.1-py3-none-any.whl
v0.4.1 · released 2025-06-13

Yes, if you support Python 3.7–3.11 and need bulletproof timeout and cancellation semantics in asyncio code. The package is low-friction to install and has no dependencies. On Python 3.12+, it transparently uses the builtin implementation, so it is safe to leave in place during version upgrades. If you only target Python 3.12+, the builtin asyncio.wait_for is sufficient and this package is unnecessary.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.7 or later; on Python 3.12+ the package delegates to the builtin asyncio.wait_for unless a race_handler is explicitly provided.
  • Low install friction; pure Python wheel with no runtime dependencies.
  • Maintenance status is aging (last release June 2025, 427 days old), but the repository remains active and the package is explicitly designed to become unnecessary on Python 3.12+, where the builtin asyncio.wait_for was fixed.

License · maintenance · safety

Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), imposing no significant restrictions on use or redistribution in most contexts.

last release 2025-06-13 (427 days) · last repo commit 2025-06-13 · 3 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 330,746 downloads/mo, #7,531 on PyPI

Verify before relying

import asyncio
import wait_for2

task = asyncio.create_task(...)

try:
    result = await wait_for2.wait_for(task, 5.0)
except wait_for2.CancelledWithResultError as e:
    # Handle simultaneous cancellation and result
    result = e.result
    raise asyncio.CancelledError()
  • Whether the package's race-condition handling callbacks (race_handler parameter) are thread-safe or have any async-context limitations.
  • Performance overhead of wait_for2 compared to builtin asyncio.wait_for on Python 3.10–3.11.
Same gist for agents: .md · .json

What it is and what it does

wait_for2 is a drop-in replacement for asyncio.wait_for() that addresses a family of race conditions present in Python's builtin implementation across versions 3.7–3.11. When a timeout fires and the inner future completes simultaneously, or when cancellation and completion occur at the same time, the builtin asyncio.wait_for() can either lose the future's result or ignore the cancellation request, depending on the Python version. wait_for2 instead raises a CancelledWithResultError that contains both the cancellation signal and the result, allowing caller code to decide how to handle the edge case. Alternatively, a callback-based race_handler can be provided to process the result without raising an exception.

The package is explicitly designed as a compatibility shim: on Python 3.12+, where the builtin asyncio.wait_for was fixed, wait_for2 delegates to the standard library unless a race_handler is explicitly passed. For Python 3.7–3.11, it provides consistent, predictable behavior across all versions and implementations (CPython and PyPy). It has no runtime dependencies and installs as a pure Python wheel.

Use it for

  • Ensuring timeout and cancellation safety in asyncio code that must support Python 3.7–3.11 without losing results or cancellation signals.
  • Handling edge cases where a task completes and is cancelled in the same event-loop cycle, using either exception handling or a callback.
  • Migrating legacy asyncio code from Python 3.7–3.10 to newer versions while maintaining consistent race-condition semantics.
  • Building robust async libraries that need predictable timeout behavior across multiple Python versions and implementations.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you support Python 3.7–3.11 and need bulletproof timeout and cancellation semantics in asyncio code.

The package is low-friction to install and has no dependencies. On Python 3.12+, it transparently uses the builtin implementation, so it is safe to leave in place during version upgrades. If you only target Python 3.12+, the builtin asyncio.wait_for is sufficient and this package is unnecessary.

Install

wait-for2 on PyPI

Before you install

Low install friction; pure Python wheel with no runtime dependencies. Maintenance status is aging (last release June 2025, 427 days old), but the repository remains active and the package is explicitly designed to become unnecessary on Python 3.12+, where the builtin asyncio.wait_for was fixed.

Requires Python 3.7 or later; on Python 3.12+ the package delegates to the builtin asyncio.wait_for unless a race_handler is explicitly provided.

License in practice

Licensed under Apache-2.0 (permissive), imposing no significant restrictions on use or redistribution in most contexts.

Quickstart

import asyncio
import wait_for2

task = asyncio.create_task(...)

try:
    result = await wait_for2.wait_for(task, 5.0)
except wait_for2.CancelledWithResultError as e:
    # Handle simultaneous cancellation and result
    result = e.result
    raise asyncio.CancelledError()

Verify before relying

  • Whether the package's race-condition handling callbacks (race_handler parameter) are thread-safe or have any async-context limitations.
  • Performance overhead of wait_for2 compared to builtin asyncio.wait_for on Python 3.10–3.11.

Package facts

LicenseApache-2.0 permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceAging 427 days since the last release
Last repo commit
First released
Downloads330,746 / month, #7,531 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Intended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Evidence: wait_for2-0.4.1-py3-none-any.whl

Tags

Capabilities
asyncio wait_for race conditionasyncio timeout cancellation edge casespython async timeout handlingasyncio simultaneous cancel and resultcross-version asyncio compatibilityasyncio wait_for alternative implementation
Topics
asyncio-compatibilityrace-condition-handling

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “asyncio wait_for race condition”

  • wait-for2Provides an alternate implementation of asyncio.wait_for() that…
  • aiohappyeyeballsImplements Happy Eyeballs (RFC 8305) connection establishment for…
  • async-interruptProvides an asyncio context manager that interrupts a block of code…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also async-timeout · aiotools · aiorun · async-interrupt · clarifai-protocol · waiting · polling2 · pytest-race · stopit · interruptingcow