From 4090932fca3dc7f12edf7a3d3d2258bd0481f3c5 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Sun, 1 Dec 2013 13:06:24 +0530 Subject: [PATCH] [minor] add locking to scheduler --- webnotes/utils/file_lock.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webnotes/utils/file_lock.py b/webnotes/utils/file_lock.py index 4665d78909..0322355a36 100644 --- a/webnotes/utils/file_lock.py +++ b/webnotes/utils/file_lock.py @@ -6,6 +6,7 @@ class LockTimeoutError(Exception): pass def create_lock(name): + pre lock_path = get_lock_path(name) if not check_lock(lock_path): return touch_file(lock_path) @@ -20,14 +21,14 @@ def touch_file(path): def check_lock(path): if not os.path.exists(path): return False - if time() - os.path.getmtime(path) > 600: + if time() - os.path.mtime(path) > 600: raise LockTimeoutError(path) return True def delete_lock(name): lock_path = get_lock_path(name) try: - os.remove(lock_path) + os.remove(path) except OSError: pass return True