AioLogic is a GIL-powered locking library for Python (current version 0.16.0) that provides synchronization primitives which are both async-aware and thread-aware. It addresses common challenges in concurrent programming by enabling seamless interaction between asynchronous code (within and across multiple threads/event loops) and synchronous code, and between different synchronous threads, offering a unified API for various concurrency models. The library is actively maintained with a focus on performance and broad compatibility.
pip install aiologicVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how `aiologic.Lock` can synchronize access to a shared resource across multiple asyncio event loops running in different OS threads. Standard `asyncio.Lock` would raise a RuntimeError, and `threading.Lock` would cause a deadlock in such a scenario.
Repickle any `aiologic` objects after upgrading to 0.13.0 or newer. Review code for potential type annotation ambiguities if using specific IDEs or strict type checkers.
Always use `aiologic.Lock` (or other `aiologic` primitives) when synchronization is required between different event loops, between async and sync code, or in complex multi-threaded async applications.
Migrate usage from `aiologic.lowlevel.shield()` to `aiologic.lowlevel.repeat_if_cancelled()` for robust cancellation handling.
Be aware of the new library detection timing. If experiencing unexpected behavior related to concurrency library integration, ensure all relevant libraries are imported before `aiologic` primitives are used.
Use `aiologic.Lock` instead. `aiologic` primitives are designed to be both async-aware and thread-aware, allowing synchronization across different event loops in separate threads.
Replace `threading.Lock` with `aiologic.Lock`. `aiologic.Lock` provides a non-blocking, async-aware, and thread-safe mechanism for synchronization.
Ensure you are using the correct `aiologic` primitive (`aiologic.Lock`, `aiologic.Condition`, etc.) for your context. `aiologic` primitives expose both synchronous (e.g., `acquire()`, `release()`) and asynchronous (e.g., `async_acquire()`, `async_release()`, or `async with`) interfaces that adapt to the environment.