pypet/utils/mpwrappers.py
def _unlock(self, name, client_id, request_id):
        """Handles unlocking"""
        if name in self._locks:
            other_client_id, other_request_id, lock_time = self._locks[name]
            if other_client_id != client_id:
                response = (self.RELEASE_ERROR + self.DELIMITER +
                            'Lock `%s` was acquired by `%s` (old request id `%s`) and not by '
                            '`%s` (request id `%s`)' % (name,
                                                        other_client_id,
                                                        other_request_id,
                                                        client_id,
                                                        request_id))
                self._logger.error(response)
                return response
            else:
                del self._locks[name]
                return self.RELEASED
        elif (name, client_id) in self._timeout_locks:
            other_request_id, lock_time = self._timeout_locks[(name, client_id)]
            timeout = time.time() - lock_time - self._timeout
            response = (self.RELEASE_ERROR + self.DELIMITER +
                        'Lock `%s` timed out %f seconds ago (client id `%s`, '
                        'old request id `%s`)' % (name, timeout, client_id, other_request_id))
            return response
        else:
            response = (self.RELEASE_ERROR + self.DELIMITER +
                        'Lock `%s` cannot be found in database (client id `%s`, '
                        'request id `%s`)' % (name, client_id, request_id))
            self._logger.warning(response)
            return response
def _unlock(self, name, client_id, request_id):
        """Handles unlocking"""
        if name in self._locks:
            other_client_id, other_request_id, lock_time = self._locks[name]
            if other_client_id != client_id:
                response = (self.RELEASE_ERROR + self.DELIMITER +
                            'Lock `%s` was acquired by `%s` (old request id `%s`) and not by '
                            '`%s` (request id `%s`)' % (name,
                                                        other_client_id,
                                                        other_request_id,
                                                        client_id,
                                                        request_id))
                self._logger.error(response)
                return response
            else:
                del self._locks[name]
                return self.RELEASED
        elif (name, client_id) in self._timeout_locks:
            other_request_id, lock_time = self._timeout_locks[(name, client_id)]
            timeout = time.time() - lock_time - self._timeout
            response = (self.RELEASE_ERROR + self.DELIMITER +
                        'Lock `%s` timed out %f seconds ago (client id `%s`, '
                        'old request id `%s`)' % (name, timeout, client_id, other_request_id))
            return response
        else:
            response = (self.RELEASE_ERROR + self.DELIMITER +
                        'Lock `%s` cannot be found in database (client id `%s`, '
                        'request id `%s`)' % (name, client_id, request_id))
            self._logger.warning(response)
            return response
Handles unlocking