示例#1
0
 def second_lock(self):
     lock = FileLock(self.testfile, timeout=0)
     try:
         lock.acquire()
     except FileLockException:
         sys.exit(1)
     lock.release()
示例#2
0
 def test_stale(self):
     """Handling of stale lock files."""
     lock = FileLock(self.testfile)
     lockfile = open(lock.lockfile, 'w')
     lock.acquire()
     lockfile.close()
     lock.release()
示例#3
0
 def second_lock(self):
     lock = FileLock(self.testfile, timeout=0)
     try:
         lock.acquire()
     except FileLockException:
         sys.exit(1)
     lock.release()
示例#4
0
 def test_stale(self):
     """Handling of stale lock files."""
     lock = FileLock(self.testfile)
     lockfile = open(lock.lockfile, 'w')
     lock.acquire()
     lockfile.close()
     lock.release()
示例#5
0
 def test_lock(self):
     """Basic locking test."""
     lock = FileLock(self.testfile)
     lock.acquire()
     self.assertTrue(lock.is_locked)
     self.assertTrue(lock.check_lock())
     lock.release()
     self.assertFalse(lock.is_locked)
     self.assertFalse(lock.check_lock())
示例#6
0
 def test_double(self):
     """Test of double locking."""
     lock1 = FileLock(self.testfile)
     lock2 = FileLock(self.testfile, timeout=0)
     lock1.acquire()
     self.assertRaises(FileLockException, lock2.acquire)
     lock1.release()
     lock2.acquire()
     lock2.release()
示例#7
0
 def test_double(self):
     """Test of double locking."""
     lock1 = FileLock(self.testfile)
     lock2 = FileLock(self.testfile, timeout=0)
     lock1.acquire()
     self.assertRaises(FileLockException, lock2.acquire)
     lock1.release()
     lock2.acquire()
     lock2.release()
示例#8
0
 def test_lock(self):
     """Basic locking test."""
     lock = FileLock(self.testfile)
     lock.acquire()
     self.assertTrue(lock.is_locked)
     self.assertTrue(lock.check_lock())
     lock.release()
     self.assertFalse(lock.is_locked)
     self.assertFalse(lock.check_lock())
示例#9
0
 def test_stale(self):
     '''
     Handling of stale lock files.
     '''
     lock = FileLock('lock-test')
     lockfile = open(lock.lockfile, 'w')
     lock.acquire()
     lockfile.close()
     lock.release()
示例#10
0
 def test_lock_twice(self):
     '''
     Basic locking test.
     '''
     lock = FileLock('lock-test')
     lock.acquire()
     lock.acquire()
     self.assertTrue(lock.is_locked)
     lock.release()
     self.assertFalse(lock.is_locked)
示例#11
0
 def test_lock_twice(self):
     '''
     Basic locking test.
     '''
     lock = FileLock(self.testfile)
     lock.acquire()
     lock.acquire()
     self.assertTrue(lock.is_locked)
     lock.release()
     self.assertFalse(lock.is_locked)
示例#12
0
 def test_lock(self):
     '''
     Basic locking test.
     '''
     lock = FileLock('lock-test')
     lock.acquire()
     self.assertTrue(lock.is_locked)
     self.assertTrue(lock.check_lock())
     lock.release()
     self.assertFalse(lock.is_locked)
     self.assertFalse(lock.check_lock())
示例#13
0
 def test_double(self):
     '''
     Test of double locking.
     '''
     lock1 = FileLock('lock-test')
     lock2 = FileLock('lock-test', timeout=0)
     lock1.acquire()
     self.assertRaises(FileLockException, lock2.acquire)
     lock1.release()
     lock2.acquire()
     lock2.release()
示例#14
0
 def test_process(self):
     """Test of double locking."""
     lock = FileLock(self.testfile)
     lock.acquire()
     try:
         process = Process(target=self.second_lock)
         process.start()
         process.join()
         self.assertEqual(process.exitcode, 1)
     finally:
         lock.release()
     process = Process(target=self.second_lock)
     process.start()
     process.join()
     self.assertEqual(process.exitcode, 0)
示例#15
0
 def test_process(self):
     '''
     Test of double locking.
     '''
     lock = FileLock(self.testfile)
     lock.acquire()
     process = Process(target=self.second_lock)
     process.start()
     process.join()
     self.assertEqual(process.exitcode, 1)
     lock.release()
     process = Process(target=self.second_lock)
     process.start()
     process.join()
     self.assertEqual(process.exitcode, 0)
示例#16
0
 def test_process(self):
     '''
     Test of double locking.
     '''
     lock = FileLock('lock-test')
     lock.acquire()
     process = Process(target=self.second_lock)
     process.start()
     process.join()
     self.assertEqual(process.exitcode, 1)
     lock.release()
     process = Process(target=self.second_lock)
     process.start()
     process.join()
     self.assertEqual(process.exitcode, 0)
示例#17
0
 def second_lock(self):
     lock = FileLock(self.testfile, timeout=0)
     lock.acquire()
     lock.release()
示例#18
0
 def second_lock(self):
     lock = FileLock(self.testfile, timeout=0)
     lock.acquire()
     lock.release()
示例#19
0
 def second_lock(self):
     lock = FileLock('lock-test', timeout=0)
     lock.acquire()
     lock.release()