From cba932362f25cb6a966bc6b3a3bc1d0f02955b1f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 27 Jan 2018 20:41:19 +0530 Subject: [PATCH] ... --- src/calibre/ptempfile.py | 4 ++-- src/calibre/utils/test_lock.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/ptempfile.py b/src/calibre/ptempfile.py index 34376ca3e1..74f711bcfa 100644 --- a/src/calibre/ptempfile.py +++ b/src/calibre/ptempfile.py @@ -339,7 +339,7 @@ else: f.close() -def tdirs_in(b): +def tdirs_in(b, check_for_lock=False): try: tdirs = os.listdir(b) except EnvironmentError as e: @@ -348,7 +348,7 @@ def tdirs_in(b): tdirs = () for x in tdirs: x = os.path.join(b, x) - if os.path.isdir(x): + if os.path.isdir(x) and (not check_for_lock or os.path.exists(os.path.join(x, TDIR_LOCK))): yield x diff --git a/src/calibre/utils/test_lock.py b/src/calibre/utils/test_lock.py index 9a257360a1..2e73653fcf 100644 --- a/src/calibre/utils/test_lock.py +++ b/src/calibre/utils/test_lock.py @@ -135,7 +135,7 @@ class IPCLockTest(unittest.TestCase): child = run_worker('calibre.utils.test_lock', 'other4') tdirs = [] while not tdirs: - tdirs = list(tdirs_in('t')) + tdirs = list(tdirs_in('t', check_for_lock=True)) self.assertTrue(is_tdir_locked(tdirs[0])) c2 = run_worker('calibre.utils.test_lock', 'other5') c2.wait()