當前位置: 首頁>>代碼示例>>Python>>正文


Python errno.EDEADLK屬性代碼示例

本文整理匯總了Python中errno.EDEADLK屬性的典型用法代碼示例。如果您正苦於以下問題:Python errno.EDEADLK屬性的具體用法?Python errno.EDEADLK怎麽用?Python errno.EDEADLK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在errno的用法示例。


在下文中一共展示了errno.EDEADLK屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def read(self, size):
        while len(self.buffer) < size:
            self.ensure_connection()

            try:
                packet = self.socket.recv(self.buffer_size)
            except socket.error as error:
                if error.errno in (EDEADLK, EAGAIN, EWOULDBLOCK):
                    gevent.sleep()
                    continue
                six.raise_from(NSQSocketError(*error.args), error)

            if not packet:
                self.close()

            self.buffer += packet

        data = self.buffer[:size]
        self.buffer = self.buffer[size:]

        return data 
開發者ID:wtolson,項目名稱:gnsq,代碼行數:23,代碼來源:stream.py

示例2: cpu_affinity_set

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def cpu_affinity_set(self, cpus):
            # Pre-emptively check if CPUs are valid because the C
            # function has a weird behavior in case of invalid CPUs,
            # see: https://github.com/giampaolo/psutil/issues/586
            allcpus = tuple(range(len(per_cpu_times())))
            for cpu in cpus:
                if cpu not in allcpus:
                    raise ValueError("invalid CPU #%i (choose between %s)"
                                     % (cpu, allcpus))
            try:
                cext.proc_cpu_affinity_set(self.pid, cpus)
            except OSError as err:
                # 'man cpuset_setaffinity' about EDEADLK:
                # <<the call would leave a thread without a valid CPU to run
                # on because the set does not overlap with the thread's
                # anonymous mask>>
                if err.errno in (errno.EINVAL, errno.EDEADLK):
                    for cpu in cpus:
                        if cpu not in allcpus:
                            raise ValueError(
                                "invalid CPU #%i (choose between %s)" % (
                                    cpu, allcpus))
                raise 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:25,代碼來源:_psbsd.py

示例3: read

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def read(socket, n=4096):
    """
    Reads at most n bytes from socket
    """

    recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)

    if six.PY3 and not isinstance(socket, NpipeSocket):
        select.select([socket], [], [])

    try:
        if hasattr(socket, 'recv'):
            return socket.recv(n)
        if six.PY3 and isinstance(socket, getattr(pysocket, 'SocketIO')):
            return socket.read(n)
        return os.read(socket.fileno(), n)
    except EnvironmentError as e:
        if e.errno not in recoverable_errors:
            raise 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:21,代碼來源:socket.py

示例4: cpu_affinity_set

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def cpu_affinity_set(self, cpus):
        # Pre-emptively check if CPUs are valid because the C
        # function has a weird behavior in case of invalid CPUs,
        # see: https://github.com/giampaolo/psutil/issues/586
        allcpus = tuple(range(len(per_cpu_times())))
        for cpu in cpus:
            if cpu not in allcpus:
                raise ValueError("invalid CPU #%i (choose between %s)"
                                 % (cpu, allcpus))
        try:
            cext.proc_cpu_affinity_set(self.pid, cpus)
        except OSError as err:
            # 'man cpuset_setaffinity' about EDEADLK:
            # <<the call would leave a thread without a valid CPU to run
            # on because the set does not overlap with the thread's
            # anonymous mask>>
            if err.errno in (errno.EINVAL, errno.EDEADLK):
                for cpu in cpus:
                    if cpu not in allcpus:
                        raise ValueError("invalid CPU #%i (choose between %s)"
                                         % (cpu, allcpus))
            raise 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:24,代碼來源:_psbsd.py

示例5: _lock

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def _lock(self):
        """Lock the entire multistore."""
        self._thread_lock.acquire()
        try:
            self._file.open_and_lock()
        except (IOError, OSError) as e:
            if e.errno == errno.ENOSYS:
                logger.warn('File system does not support locking the '
                            'credentials file.')
            elif e.errno == errno.ENOLCK:
                logger.warn('File system is out of resources for writing the '
                            'credentials file (is your disk full?).')
            elif e.errno == errno.EDEADLK:
                logger.warn('Lock contention on multistore file, opening '
                            'in read-only mode.')
            elif e.errno == errno.EACCES:
                logger.warn('Cannot access credentials file.')
            else:
                raise
        if not self._file.is_locked():
            self._read_only = True
            if self._warn_on_readonly:
                logger.warn('The credentials file (%s) is not writable. '
                            'Opening in read-only mode. Any refreshed '
                            'credentials will only be '
                            'valid for this run.', self._file.filename())

        if os.path.getsize(self._file.filename()) == 0:
            logger.debug('Initializing empty multistore file')
            # The multistore is empty so write out an empty file.
            self._data = {}
            self._write()
        elif not self._read_only or self._data is None:
            # Only refresh the data if we are read/write or we haven't
            # cached the data yet. If we are readonly, we assume is isn't
            # changing out from under us and that we only have to read it
            # once. This prevents us from whacking any new access keys that
            # we have cached in memory but were unable to write out.
            self._refresh_data_cache() 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:41,代碼來源:multistore_file.py

示例6: open_with_flock

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def open_with_flock(*args, **kwargs):
    """ Context manager for opening file with an exclusive lock. """
    f = open(*args, **kwargs)
    try:
        fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
    except IOError:
        no_attempt = 0
        while no_attempt < MAX_ATTEMPTS:
            try:
                logging.info("Can't immediately write-lock the file ({0}), waiting.".format(f.name))
                start_time = time.time()
                fcntl.lockf(f, fcntl.LOCK_EX)
                break
            except IOError as e:
                if e.errno == errno.EDEADLK:
                    logging.warn("The OS complained because the process have been waiting on the lockf for {0} sec with the error ({1}: {2}). Retrying. ".format(time.time() - start_time, e.errno, e.strerror))
                    f.close()
                    time.sleep(TIME_BETWEEN_ATTEMPTS)
                    f = open(*args, **kwargs)
                    no_attempt += 1
                else:
                    raise e

        if no_attempt == MAX_ATTEMPTS:
            raise IOError("Failed to lock {0} {1} times.".format(f.name, MAX_ATTEMPTS))

    try:
        yield f
    finally:
        fcntl.lockf(f, fcntl.LOCK_UN)
        f.close() 
開發者ID:SMART-Lab,項目名稱:smartdispatch,代碼行數:33,代碼來源:filelock.py

示例7: _lock

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def _lock(self):
        """Lock the entire multistore."""
        self._thread_lock.acquire()
        try:
            self._file.open_and_lock()
        except IOError as e:
            if e.errno == errno.ENOSYS:
                logger.warn('File system does not support locking the '
                            'credentials file.')
            elif e.errno == errno.ENOLCK:
                logger.warn('File system is out of resources for writing the '
                            'credentials file (is your disk full?).')
            elif e.errno == errno.EDEADLK:
                logger.warn('Lock contention on multistore file, opening '
                            'in read-only mode.')
            elif e.errno == errno.EACCES:
                logger.warn('Cannot access credentials file.')
            else:
                raise
        if not self._file.is_locked():
            self._read_only = True
            if self._warn_on_readonly:
                logger.warn('The credentials file (%s) is not writable. '
                            'Opening in read-only mode. Any refreshed '
                            'credentials will only be '
                            'valid for this run.', self._file.filename())
        if os.path.getsize(self._file.filename()) == 0:
            logger.debug('Initializing empty multistore file')
            # The multistore is empty so write out an empty file.
            self._data = {}
            self._write()
        elif not self._read_only or self._data is None:
            # Only refresh the data if we are read/write or we haven't
            # cached the data yet. If we are readonly, we assume is isn't
            # changing out from under us and that we only have to read it
            # once. This prevents us from whacking any new access keys that
            # we have cached in memory but were unable to write out.
            self._refresh_data_cache() 
開發者ID:luci,項目名稱:luci-py,代碼行數:40,代碼來源:multistore_file.py

示例8: handle_error

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def handle_error(self):
        error = sys.exc_info()[1]
        if sys.exc_info()[0] is socket.error:
            if error.errno != errno.EAGAIN and error.errno != errno.EDEADLK:
                self.logger.exception("Received error", extra=self._logger_extras)
                self.close(IOError(error))
        else:
            self.logger.warning("Received unexpected error: " + str(error), extra=self._logger_extras) 
開發者ID:hazelcast,項目名稱:hazelcast-python-client,代碼行數:10,代碼來源:reactor.py

示例9: _lock

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def _lock(self):
        """Lock the entire multistore."""
        self._thread_lock.acquire()
        try:
            self._file.open_and_lock()
        except IOError as e:
            if e.errno == errno.ENOSYS:
                logger.warn('File system does not support locking the '
                            'credentials file.')
            elif e.errno == errno.ENOLCK:
                logger.warn('File system is out of resources for writing the '
                            'credentials file (is your disk full?).')
            elif e.errno == errno.EDEADLK:
                logger.warn('Lock contention on multistore file, opening '
                            'in read-only mode.')
            else:
                raise
        if not self._file.is_locked():
            self._read_only = True
            if self._warn_on_readonly:
                logger.warn('The credentials file (%s) is not writable. '
                            'Opening in read-only mode. Any refreshed '
                            'credentials will only be '
                            'valid for this run.', self._file.filename())
        if os.path.getsize(self._file.filename()) == 0:
            logger.debug('Initializing empty multistore file')
            # The multistore is empty so write out an empty file.
            self._data = {}
            self._write()
        elif not self._read_only or self._data is None:
            # Only refresh the data if we are read/write or we haven't
            # cached the data yet. If we are readonly, we assume is isn't
            # changing out from under us and that we only have to read it
            # once. This prevents us from whacking any new access keys that
            # we have cached in memory but were unable to write out.
            self._refresh_data_cache() 
開發者ID:jmankoff,項目名稱:data,代碼行數:38,代碼來源:multistore_file.py

示例10: cpu_affinity_set

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import EDEADLK [as 別名]
def cpu_affinity_set(self, cpus):
        try:
            cext.proc_cpu_affinity_set(self.pid, cpus)
        except OSError as err:
            # 'man cpuset_setaffinity' about EDEADLK:
            # <<the call would leave a thread without a valid CPU to run
            # on because the set does not overlap with the thread's
            # anonymous mask>>
            if err.errno in (errno.EINVAL, errno.EDEADLK):
                allcpus = tuple(range(len(per_cpu_times())))
                for cpu in cpus:
                    if cpu not in allcpus:
                        raise ValueError("invalid CPU #%i (choose between %s)"
                                         % (cpu, allcpus))
            raise 
開發者ID:Azure,項目名稱:azure-linux-extensions,代碼行數:17,代碼來源:_psbsd.py


注:本文中的errno.EDEADLK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。