Example #1
0
    def test_cleanup_debris(self):
        with open(self.lockfile, 'w') as f:
            f.write('0')  # Non existent pid

        lock = PIDLock(self.lockfile)
        lock.acquire()
        self.assertTrue(lock.check())
Example #2
0
 def test_acquire_withcontext(self):
     lock = PIDLock(self.lockfile)
     with lock.acquire():
         self.assertTrue(lock.check())
     self.assertFalse(lock.check())
Example #3
0
 def test_release(self):
     lock = PIDLock(self.lockfile)
     lock.acquire()
     lock.release()
     self.assertFalse(lock.check())
Example #4
0
 def test_acquire_again(self):
     lock = PIDLock(self.lockfile)
     with lock.acquire():
         self.assertRaises(PIDLockException, lock.acquire)
Example #5
0
 def test_acquire(self):
     lock = PIDLock(self.lockfile)
     lock.acquire()
     self.assertTrue(lock.check())