当前位置: 首页>>代码示例>>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;未经允许,请勿转载。