PyMySQLLock package¶
Submodules¶
PyMySQLLock.connection_factory module¶
PyMySQLLock.lock module¶
-
class
PyMySQLLock.lock.Lock(locker, name)[source]¶ Bases:
objectRepresents a lock object which has one-to-one correspondence with a Mysql connection. A lock is held by a connection.
-
acquire(timeout=-1, refresh_interval_secs=10)[source]¶ Try to obtain lock with the set name.
Parameters: - timeout – Timeout for getting the lock in seconds. Defaults to -1 which will wait for indefinite time.
- refresh_interval_secs – Interval at which a thread will keep pinging on mysql connection that’s holding the lock.
Returns: The return value is True if the lock is acquired successfully, False if not (for example if the
timeout expired).
-
PyMySQLLock.locker module¶
Main module.
-
class
PyMySQLLock.locker.Locker(*args, **kwargs)[source]¶ Bases:
objectLocker is primary interface to user with this library. Locker is used to create locks with given name.
-
get_all_locks()[source]¶ Get all locks queries mysql metadata table to get all user acquired locks.
Returns: list of locks acquired on the given mysql database
-
lock(name)[source]¶ Creates and returns a Lock object with given name. :param name: Name of the lock. :return: A Lock object.
-
lock_class¶ alias of
PyMySQLLock.lock.Lock
-