当前位置: 首页>>代码示例>>Python>>正文


Python errno.ETIMEDOUT属性代码示例

本文整理汇总了Python中errno.ETIMEDOUT属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ETIMEDOUT属性的具体用法?Python errno.ETIMEDOUT怎么用?Python errno.ETIMEDOUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在errno的用法示例。


在下文中一共展示了errno.ETIMEDOUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_connect_ex_error

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_connect_ex_error(self):
        with support.transient_internet(REMOTE_HOST):
            s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                                cert_reqs=ssl.CERT_REQUIRED,
                                ca_certs=REMOTE_ROOT_CERT)
            try:
                rc = s.connect_ex((REMOTE_HOST, 444))
                # Issue #19919: Windows machines or VMs hosted on Windows
                # machines sometimes return EWOULDBLOCK.
                errors = (
                    errno.ECONNREFUSED, errno.EHOSTUNREACH, errno.ETIMEDOUT,
                    errno.EWOULDBLOCK,
                )
                self.assertIn(rc, errors)
            finally:
                s.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_ssl.py

示例2: read

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def read(self, timeout):
        if self.tty is not None:
            self.tty.timeout = max(timeout/1E3, 0.05)
            frame = bytearray(self.tty.read(6))
            if frame is None or len(frame) == 0:
                raise IOError(errno.ETIMEDOUT, os.strerror(errno.ETIMEDOUT))
            if frame.startswith(b"\x00\x00\xff\x00\xff\x00"):
                log.log(logging.DEBUG-1, "<<< %s", hexlify(frame).decode())
                return frame
            LEN = frame[3]
            if LEN == 0xFF:
                frame += self.tty.read(3)
                LEN = frame[5] << 8 | frame[6]
            frame += self.tty.read(LEN + 1)
            log.log(logging.DEBUG-1, "<<< %s", hexlify(frame).decode())
            return frame 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:18,代码来源:transport.py

示例3: send_rsp_recv_cmd

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def send_rsp_recv_cmd(self, target, data, timeout):
        # print("\n".join(self._print_ciu_register_page(0, 1)))
        if target.tt3_cmd:
            return self._tt3_send_rsp_recv_cmd(target, data, timeout)
        try:
            if data:
                self.chipset.tg_response_to_initiator(data)
            return self.chipset.tg_get_initiator_command(timeout)
        except Chipset.Error as error:
            if error.errno in (0x0A, 0x29, 0x31):
                self.log.debug("Error: %s", error)
                raise nfc.clf.BrokenLinkError(str(error))
            else:
                self.log.warning(error)
                raise nfc.clf.TransmissionError(str(error))
        except IOError as error:
            if error.errno == errno.ETIMEDOUT:
                info = "no data received within %.3f s" % timeout
                self.log.debug(info)
                raise nfc.clf.TimeoutError(info)
            else:
                # host-controller communication broken
                self.log.error(error)
                raise error 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:26,代码来源:pn53x.py

示例4: test_send_cmd_recv_rsp_transport_error

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_send_cmd_recv_rsp_transport_error(self, device, err, exc):
        device.chipset.transport.read.side_effect = [
            ACK(), self.reg_rsp('00 00 00'),              # ReadRegister
            ACK(), RSP('09 00'),                          # WriteRegister
            ACK(), RSP('33'),                             # RFConfiguration
            ACK(), IOError(err, "test"),                  # InCommunicateThru
        ]
        target = nfc.clf.RemoteTarget('106A')
        with pytest.raises(exc):
            device.send_cmd_recv_rsp(target, b'123', 1.0)
        assert device.chipset.transport.write.mock_calls == [call(_) for _ in [
            CMD('06 6302 6303 6305'),                     # ReadRegister
            CMD('08 630200 630300 630540'),               # WriteRegister
            CMD('32 020a0b0f'),                           # RFConfiguration
            CMD('42 313233'),                             # InCommunicateThru
        ] + ([ACK()] if err == errno.ETIMEDOUT else [])] 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:18,代码来源:base_clf_pn53x.py

示例5: test_listen_tta_as_tt4_rcvd_deselect

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_listen_tta_as_tt4_rcvd_deselect(self, device):
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 00 E0 80'),                  # TgInitAsTarget
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), RSP('89 00 C03233'),                 # TgGetInitiatorCommand
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgInitAsTarget
        ]
        target = nfc.clf.LocalTarget('106A')
        target.sens_res = HEX("4400")
        target.sel_res = HEX("20")
        target.sdd_res = HEX("08010203")
        assert device.listen_tta(target, 1.0) is None
        assert device.chipset.transport.read.call_count == 12
        device.chipset.transport.write.assert_any_call(CMD('90 0578807002')) 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:18,代码来源:base_clf_pn53x.py

示例6: test_listen_dep_ioerror_timeout_after_psl

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_listen_dep_ioerror_timeout_after_psl(self, device):
        atr_req = 'D400 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        psl_req = 'D404 00 12 03'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), RSP('89 00 06' + psl_req),           # TgGetInitiatorCommand
            ACK(), self.reg_rsp('FD'),                  # ReadRegister
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), self.reg_rsp('FD'),                  # ReadRegister
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgGetInitiatorCommand
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        assert device.listen_dep(target, 1.0) is None
        assert device.chipset.transport.read.call_count == 20 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:26,代码来源:base_clf_pn53x.py

示例7: test_listen_dep_ioerror_timeout_after_atr

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_listen_dep_ioerror_timeout_after_atr(self, device):
        atr_req = 'D400 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgGetInitiatorCommand
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        assert device.listen_dep(target, 1.0) is None
        assert device.chipset.transport.read.call_count == 8 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:19,代码来源:base_clf_pn53x.py

示例8: test_listen_dep_not_atr_and_then_ioerror

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_listen_dep_not_atr_and_then_ioerror(self, device):
        atr_req = 'D4FF 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgInitAsTarget
            ACK(), IOError(errno.EIO, ""),              # TgInitAsTarget
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        with pytest.raises(IOError):
            device.listen_dep(target, 1.0)
        assert device.chipset.transport.read.call_count == 8 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:20,代码来源:base_clf_pn53x.py

示例9: test_listen_dep_ioerror_timeout_after_atr

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_listen_dep_ioerror_timeout_after_atr(self, device):
        atr_req = 'D400 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('19'),                           # ResetMode
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('33'),                           # RFConfiguration
            ACK(), RSP('13'),                           # SetParameters
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), RSP('93 00'),                        # TgSetGeneralBytes
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgGetInitiatorCommand
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        assert device.listen_dep(target, 1.0) is None
        assert device.chipset.transport.read.call_count == 16 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:23,代码来源:test_clf_rcs956.py

示例10: test_listen_dep_not_atr_and_then_ioerror

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def test_listen_dep_not_atr_and_then_ioerror(self, device):
        atr_req = 'D4FF 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('19'),                           # ResetMode
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('33'),                           # RFConfiguration
            ACK(), RSP('13'),                           # SetParameters
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgInitAsTarget
            ACK(), IOError(errno.EIO, ""),              # TgInitAsTarget
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        with pytest.raises(IOError):
            device.listen_dep(target, 1.0)
        assert device.chipset.transport.read.call_count == 16 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:24,代码来源:test_clf_rcs956.py

示例11: _on_local_read

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def _on_local_read(self):
        # handle all local read events and dispatch them to methods for
        # each stage
        self._update_activity()
        if not self._local_sock:
            return
        data = None
        try:
            data = self._local_sock.recv(BUF_SIZE)
        except (OSError, IOError) as e:
            if eventloop.errno_from_exception(e) in \
                    (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK):
                return
        if not data:
            self.destroy()
            return
        if not data:
            return
        self._server.server_transfer_ul += len(data)
        #TODO ============================================================
        if self._stage == STAGE_STREAM:
            self._write_to_sock(data, self._remote_sock)
            return 
开发者ID:shadowsocksr-backup,项目名称:shadowsocksr,代码行数:25,代码来源:udprelay.py

示例12: init_database

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def init_database(self):
        """
        Initializes the database connection to MongoDB.
        Also pre-caches potentially heavy resources from the DB.
        :return:
        """
        self.log.info('Connecting to Database...')
        self.db = Database(self, self.cfg.db)
        try:
            await self.db[self.db.db_nam].collection.find_one({})
            if self.cfg.cache.type not in ['redis', 'mixed']:
                await self.db.precache_settings()
                await self.db.precache_profiles()
                await self.db.precache_resources()
            set_color_cache_coll(self.db[self.db.db_nam].ColorCache)
        except ServerSelectionTimeoutError:
            self.log.error('A Connection To The Database Host Failed!')
            exit(errno.ETIMEDOUT)
        except OperationFailure:
            self.log.error('Database Access Operation Failed!')
            exit(errno.EACCES)
        self.log.info('Successfully Connected to Database') 
开发者ID:lu-ci,项目名称:apex-sigma-core,代码行数:24,代码来源:sigma.py

示例13: acquire

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def acquire(self, block=True, timeout=None):
        if self.kind == RECURSIVE_MUTEX and self._is_mine():
            self.count += 1
            return True

        if block and timeout is None:
            res = pthread.sem_wait(self.handle)
        elif not block or timeout <= 0:
            res = pthread.sem_trywait(self.handle)
        else:
            res = _sem_timedwait(self.handle, timeout)
        if res < 0:
            e = ctypes.get_errno()
            if e == errno.EINTR:
                return None
            elif e in [errno.EAGAIN, errno.ETIMEDOUT]:
                return False
            raiseFromErrno()
        self.count += 1
        self.ident = get_ident()
        return True 
开发者ID:joblib,项目名称:loky,代码行数:23,代码来源:semlock.py

示例14: _on_local_read

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def _on_local_read(self):
        # handle all local read events and dispatch them to methods for
        # each stage
        if not self._local_sock:
            return
        is_local = self._is_local
        data = None
        try:
            data = self._local_sock.recv(BUF_SIZE)
        except (OSError, IOError) as e:
            if eventloop.errno_from_exception(e) in \
                    (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK):
                return
        if not data:
            self.destroy()
            return
        self._update_activity(len(data))
        if not is_local:
            data = self._encryptor.decrypt(data)
            if not data:
                return
        if self._stage == STAGE_STREAM:
            if self._is_local:
                data = self._encryptor.encrypt(data)
            self._write_to_sock(data, self._remote_sock)
            return
        elif is_local and self._stage == STAGE_INIT:
            # TODO check auth method
            self._write_to_sock(b'\x05\00', self._local_sock)
            self._stage = STAGE_ADDR
            return
        elif self._stage == STAGE_CONNECTING:
            self._handle_stage_connecting(data)
        elif (is_local and self._stage == STAGE_ADDR) or \
                (not is_local and self._stage == STAGE_INIT):
            self._handle_stage_addr(data) 
开发者ID:ntfreedom,项目名称:neverendshadowsocks,代码行数:38,代码来源:tcprelay.py

示例15: _on_remote_read

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ETIMEDOUT [as 别名]
def _on_remote_read(self):
        # handle all remote read events
        data = None
        try:
            data = self._remote_sock.recv(BUF_SIZE)

        except (OSError, IOError) as e:
            if eventloop.errno_from_exception(e) in \
                    (errno.ETIMEDOUT, errno.EAGAIN, errno.EWOULDBLOCK):
                return
        if not data:
            self.destroy()
            return
        self._update_activity(len(data))
        if self._is_local:
            data = self._encryptor.decrypt(data)
        else:
            data = self._encryptor.encrypt(data)
        try:
            self._write_to_sock(data, self._local_sock)
        except Exception as e:
            shell.print_exception(e)
            if self._config['verbose']:
                traceback.print_exc()
            # TODO use logging when debug completed
            self.destroy() 
开发者ID:ntfreedom,项目名称:neverendshadowsocks,代码行数:28,代码来源:tcprelay.py


注:本文中的errno.ETIMEDOUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。