skillfed

fifolock

A flexible low-level tool to make synchronisation primitives in asyncio Python

fifolock v0.0.20 236.9K downloads/30d#8,971 on PyPI54
Permissive license Abandoned released

What it is and what it does

Fifolock is a minimal asyncio synchronization tool that lets you build custom lock types—mutexes, read/write locks, semaphores—by defining compatibility rules between lock modes. Each mode is a subclass of asyncio.Future, and the lock grants access strictly in the order requests arrive, never allowing reentrancy.

You create a FifoLock instance, define lock-mode classes with an is_compatible method that checks whether a new request can proceed given the currently held locks, then use the lock as an async context manager. The package includes recipes for common patterns like exclusive locks, shared/exclusive (read/write) locks, and bounded semaphores. It requires Python 3.5 or later and has no external dependencies.

Use it for:

  • Building a read/write lock where multiple readers can access a resource concurrently but writers get exclusive access.
  • Implementing a bounded semaphore that allows concurrent operations in strict request order.
  • Creating custom synchronization logic where lock compatibility depends on which modes are currently held.
  • Ensuring fair, deterministic lock acquisition order in asyncio applications where FIFO fairness matters.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Fifolock provides a low-level building block for creating custom synchronization primitives in asyncio Python, where locks are granted strictly in first-in-first-out order and are not reentrant.

No, unless you have an existing codebase already using it. The package is abandoned (last release 2019-05-02, no commits since), and asyncio now includes built-in primitives that cover most common use cases. If you need custom lock semantics, consider maintaining a fork or using a maintained alternative.

Install

fifolock on PyPI

pip

pip install fifolock

uv

uv add fifolock

poetry

poetry add fifolock

Installing fifolock

Before you install

Installation is frictionless—a pure Python wheel with no runtime dependencies. However, the project is abandoned; the last commit was 2019-05-02 and no releases have occurred since.

License in practice

Licensed under MIT (permissive), so you can use it freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install fifolock

import asyncio
from fifolock import FifoLock

class Mutex(asyncio.Future):
    @staticmethod
    def is_compatible(holds):
        return not holds[Mutex]

lock = FifoLock()

async def access():
    async with lock(Mutex):
        pass

Requires Python 3.5 or later (requires_python: >=3.5)

Verify before relying

  • Whether the package works correctly with Python versions released after 2019.
  • Whether there are known issues or edge cases in FIFO lock ordering under high concurrency.
  • Whether alternative asyncio lock libraries now provide similar functionality.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 2,661 days since the last release
Last repo commit
First released
Downloads 236,901/month — #8,971 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fifolock-0.0.20-py3-none-any.whl

Framework :: AsyncIOLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

asyncio synchronization primitivesfifo lock async pythoncustom async locksasyncio mutual exclusionread write lock asynciosemaphore asyncioasync lock ordering
asyncioconcurrencyabandoned

More Software Development packages