Cron Lock ========= The ``fussy.cronlock`` module provides a simple mechanism to prevent runaway cron jobs. A lock can be used to protect a piece of code that should only ever have a single running instance: .. code-block:: python from fussy import cronlock lock = cronlock.Lock( 'test.lock' ) with lock: do_something() It can also be used to prevent a piece of code from running for too long (note: the lock does not need to be held for this to work): .. code-block:: python from fussy import cronlock lock = cronlock.Lock( 'test.lock' ) lock.set_timeout( 20 ) # from this moment do_something_that_might_take_a_while() A decorator is provided to create and hold the lock for a given function, normally the main function of your cron-lock: .. code-block:: python from fussy import with_lock @with_lock( 'test.lock', timeout=20 ) def main(): """Your cron job main-loop""" Module: fussy.cronlock ---------------------- .. automodule:: fussy.cronlock :members: :special-members: