From ab56d2029f9cc06a54e7ff97106f13c86bbf064f Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Fri, 13 Nov 2015 11:38:27 -0800 Subject: [PATCH] Added a code sample I have not tested this change, I apologize for that. --- doc/source/api/process_lock.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/source/api/process_lock.rst b/doc/source/api/process_lock.rst index d4e8ebe..68036f0 100644 --- a/doc/source/api/process_lock.rst +++ b/doc/source/api/process_lock.rst @@ -17,3 +17,18 @@ Decorators ---------- .. autofunction:: fasteners.process_lock.interprocess_locked + +.. code-block:: python + # Launch multiple of these at the same time to see the lock in action + import time + import fasteners + + @fasteners.process_lock.interprocess_locked('tmp_lock_file') + def test(): + for i in range(10): + print('I have the lock') + time.sleep(1) + + + print('Waiting for the lock') + test()