Example #1
0
 def test_tdir_in_cache_dir(self):
     child = run_worker('calibre.utils.test_lock', 'other4')
     tdirs = []
     while not tdirs:
         time.sleep(0.05)
         gl = retry_lock_tdir('t', sleep=0.05)
         try:
             tdirs = list(tdirs_in('t'))
         finally:
             unlock_file(gl)
     self.assertTrue(is_tdir_locked(tdirs[0]))
     c2 = run_worker('calibre.utils.test_lock', 'other5')
     self.assertEqual(c2.wait(), 0)
     self.assertTrue(is_tdir_locked(tdirs[0]))
     child.kill(), child.wait()
     self.assertTrue(os.path.exists(tdirs[0]))
     self.assertFalse(is_tdir_locked(tdirs[0]))
     clean_tdirs_in('t')
     self.assertFalse(os.path.exists(tdirs[0]))
     self.assertEqual(os.listdir('t'), ['tdir-lock'])
Example #2
0
 def test_tdir_in_cache_dir(self):
     child = run_worker('calibre.utils.test_lock', 'other4')
     tdirs = []
     while not tdirs:
         time.sleep(0.05)
         gl = retry_lock_tdir('t', sleep=0.05)
         try:
             tdirs = list(tdirs_in('t'))
         finally:
             unlock_file(gl)
     self.assertTrue(is_tdir_locked(tdirs[0]))
     c2 = run_worker('calibre.utils.test_lock', 'other5')
     self.assertEqual(c2.wait(), 0)
     self.assertTrue(is_tdir_locked(tdirs[0]))
     child.kill(), child.wait()
     self.assertTrue(os.path.exists(tdirs[0]))
     self.assertFalse(is_tdir_locked(tdirs[0]))
     clean_tdirs_in('t')
     self.assertFalse(os.path.exists(tdirs[0]))
     self.assertEqual(os.listdir('t'), [u'tdir-lock'])