Exemplo n.º 1
0
 def test_locked_for_one_hour(self):
     self.assertTrue(acquire_lock(self.lock))
     touch = datetime.datetime.fromtimestamp(time.time() -
                                             3601).strftime("%m%d%H%M")
     os.system("touch -t %s %s" % (touch, self.lock))
     self.assertRaises(UserWarning,
                       acquire_lock,
                       self.lock,
                       max_try=2,
                       delay=1)
 def test_locked_for_one_hour(self):
     self.assertTrue(acquire_lock(self.lock))
     touch = datetime.datetime.fromtimestamp(time.time() - 3601).strftime("%m%d%H%M")
     os.system("touch -t %s %s" % (touch, self.lock))
     self.assertRaises(UserWarning, acquire_lock, self.lock, max_try=2, delay=1)
Exemplo n.º 3
0
 def test_wrong_process_and_continue(self):
     fd = os.open(self.lock, os.O_EXCL | os.O_RDWR | os.O_CREAT)
     os.write(fd, str_to_bytes('1111111111'))
     os.close(fd)
     self.assertTrue(os.path.exists(self.lock))
     self.assertTrue(acquire_lock(self.lock))
Exemplo n.º 4
0
 def test_acquire_normal(self):
     self.assertTrue(acquire_lock(self.lock, 1, 1))
     self.assertTrue(os.path.exists(self.lock))
     release_lock(self.lock)
     self.assertFalse(os.path.exists(self.lock))