--- id: pymysqllock version: "0.2.0" license: MIT license license_treatment: permissive maintenance: abandoned --- # PyMySQLLock — MySQL Backed Locking Primitive License: permissive · Maintenance: abandoned · Downloads: 255.0K/mo ## What it is and what it does PyMySQLLock wraps MySQL's GET_LOCK function to provide a simple distributed locking mechanism for coordinating work across multiple Python application instances that share a common MySQL database. Instead of adding external systems like Zookeeper or etcd, it leverages your existing MySQL infrastructure to ensure only one instance holds a lock at a time and can execute protected tasks. The package exposes a Locker class that takes standard MySQL connection parameters, then creates named Lock objects that can be acquired with optional timeouts and released when done. It maintains the lock by periodically pinging the MySQL connection in the background to prevent idle disconnection. You can also query all currently held locks on the database. Use it for: - Coordinate scheduled job execution across multiple application servers so only one instance runs a critical task at a time. - Prevent race conditions when multiple instances need exclusive access to a shared resource managed through MySQL. - Implement leader election or primary-replica coordination in a cluster without deploying additional infrastructure. - Serialize access to database operations that cannot tolerate concurrent modification from multiple application instances. - Gate one-time initialization or migration tasks that should run exactly once across a fleet of servers. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides distributed locking primitives backed by MySQL's GET_LOCK function, allowing multiple application instances to coordinate exclusive access to named resources through a shared MySQL database. No. The package is abandoned (last release 2020-09-13, no maintenance since) and classified as pre-alpha. While the concept is sound and the MIT license is permissive, the lack of updates means no fixes for bugs, compatibility issues with modern Python or MySQL versions, or security concerns. Consider a maintained alternative like a Redis-based lock library or a purpose-built distributed coordination tool unless you have a very stable, isolated deployment and can accept the risk of no future support. ## Install pip install pymysqllock uv add pymysqllock poetry add pymysqllock ## Installing PyMySQLLock Before you install: Installation is straightforward with no runtime dependencies. However, the package is abandoned—last release was 2020-09-13 with no commits or maintenance signals since. Use only if you accept the risk of unpatched issues and no future updates. License in practice: MIT license permits commercial and private use with minimal restrictions, requiring only license and copyright notice retention. Quickstart: pip install PyMySQLLock from PyMySQLLock import Locker locker = Locker(host="localhost", user="root", password="password", database="db") lock = locker.lock("lock_name") lock.acquire(timeout=10) # do something lock.release() Requires an active MySQL connection; the package works with PyMYSQL, mysql-connector-python, or mysqlclient but does not include or install any MySQL driver itself. Verify before relying: - Whether the package works reliably with modern MySQL versions and current Python 3.9+ releases beyond the declared support for 3.6–3.8. - Whether background connection refresh (ping interval) is sufficient to prevent connection timeouts in production environments. - Performance characteristics and scalability limits when many application instances contend for locks on a single MySQL database. ## Package facts - License: MIT license (permissive) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 255.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags mysql distributed lock, mysql-based locking, mysql named lock, mysql coordination primitive, mysql mutual exclusion, mysql lock acquire release, mysql shared resource lock, distributed-locking, mysql-coordination, abandoned [View on SkillFed](https://skillfed.io/packages/pymysqllock) · [View on PyPI](https://pypi.org/project/pymysqllock/)