示例#1
0
 def _release_lock(self):
     self.debug("Releasing master agency lock")
     if self._release_lock_cl is not None and \
             self._release_lock_cl.active():
         self._release_lock_cl.cancel()
     self._release_lock_cl = None
     if self._lock_file is None:
         return
     fcntl.unlock(self._lock_file.fileno())
     self._starting_master = False
     self._lock_file.close()
     self._lock_file = None
    def testLockAlreadyTaken(self):
        self.lock_fd = open(self.lock_path, 'rb+')
        if not fcntl.lock(self.lock_fd):
            self.fail("Could not take the lock")

        yield self.agency.initiate()
        yield self.wait_for_slave()

        pid = run.get_pid(os.path.curdir)
        run.term_pid(pid)
        yield self.wait_for_master_gone()
        yield common.delay(None, 10)
        pid = run.get_pid(os.path.curdir)
        self.assertTrue(pid is None)

        # remove the lock so that the broker in our
        # agency can connect and stop retrying, overwise the test
        # will finish in undefined way (this is part of the teardown)
        fcntl.unlock(self.lock_fd)
示例#3
0
 def testflockUnlock(self):
     self.assertTrue(fcntl.lock(self.lock1))
     self.assertFalse(fcntl.lock(self.lock2))
     self.assertTrue(fcntl.unlock(self.lock1))
     self.assertTrue(fcntl.lock(self.lock2))