Fifolock is a Python library providing flexible, low-level synchronization primitives for `asyncio` applications. It implements first-in-first-out (FIFO) ordered locks, ensuring requests are granted strictly in the order they are made. The current version is 0.0.20. The project appears to have an infrequent release cadence, with the last significant activity several years ago.
pip install fifolockVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic mutex using `FifoLock`. By defining a `Mutex` class that inherits from `asyncio.Future` and implementing `is_compatible`, you create a lock 'mode'. The `async with lock(Mutex):` statement ensures that only one coroutine can hold the mutex at a time, with acquisition in FIFO order.
Ensure your code logic does not attempt reentrant locking. If reentrancy is required, `FifoLock` is not the appropriate primitive.
Familiarize yourself with the 'Recipes' section of the GitHub README to understand how to define custom lock types (subclasses of `asyncio.Future`) and their `is_compatible` methods.
Only use `FifoLock` within a single `asyncio` event loop for coroutine synchronization. For inter-thread communication, consider `threading.Lock` or `Queue.Queue`.
Test thoroughly with your target Python and `asyncio` versions. Consider `asyncio.Lock` if FIFO is not strictly required, as it gained fairness guarantees in Python 3.10 and is actively maintained.
If strict FIFO ordering is a critical requirement, `FifoLock` is designed for this. Replace `asyncio.Lock` with `fifolock.FifoLock` and define appropriate `asyncio.Future` subclasses as lock modes.
Carefully review the `is_compatible` logic for each of your lock 'modes'. Ensure that the conditions for compatibility (what other locks can be held simultaneously) are correctly defined. Verify that `async with lock(Mode)` blocks are properly exited.
No dependency data recorded yet.