{"categories":[{"label":"Software Development","url":"https://skillfed.io/packages/category/software-development/9"}],"enrichment":{"capability":"Provides an alternate implementation of asyncio.wait_for() that handles race conditions between simultaneous cancellation and future completion consistently across Python 3.7\u20133.13.","skillfed_tags":["asyncio-compatibility","race-condition-handling"],"use_cases":["Ensuring timeout and cancellation safety in asyncio code that must support Python 3.7\u20133.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\u20133.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."],"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\u20133.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.\n\nThe 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\u20133.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.","worth_installing":"Yes, if you support Python 3.7\u20133.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."},"id":"wait-for2","links":{"html":"https://skillfed.io/packages/wait-for2","md":"https://skillfed.io/packages/wait-for2.md","pypi":"https://pypi.org/project/wait-for2/"},"maintenance":{"status":"aging"},"meta":{"latest_release":"2025-06-13","license_spdx":null,"license_treatment":"permissive","name":"wait-for2","python_support":"unspecified","summary":"Asyncio wait_for that can handle simultaneous cancellation and future completion."},"popularity":{"monthly_downloads":330746,"position":7531,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"0.4.1"}
