This commit is contained in:
Kovid Goyal 2018-01-27 20:41:19 +05:30
parent 231f5423dd
commit cba932362f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -339,7 +339,7 @@ else:
f.close() f.close()
def tdirs_in(b): def tdirs_in(b, check_for_lock=False):
try: try:
tdirs = os.listdir(b) tdirs = os.listdir(b)
except EnvironmentError as e: except EnvironmentError as e:
@ -348,7 +348,7 @@ def tdirs_in(b):
tdirs = () tdirs = ()
for x in tdirs: for x in tdirs:
x = os.path.join(b, x) 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 yield x

View File

@ -135,7 +135,7 @@ class IPCLockTest(unittest.TestCase):
child = run_worker('calibre.utils.test_lock', 'other4') child = run_worker('calibre.utils.test_lock', 'other4')
tdirs = [] tdirs = []
while not 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])) self.assertTrue(is_tdir_locked(tdirs[0]))
c2 = run_worker('calibre.utils.test_lock', 'other5') c2 = run_worker('calibre.utils.test_lock', 'other5')
c2.wait() c2.wait()