我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用errno.EBADFD。
def connect(self, address): if self.act_non_blocking: return self.fd.connect(address) fd = self.fd if self.gettimeout() is None: while not socket_connect(fd, address): try: self._trampoline(fd, write=True) except IOClosed: raise socket.error(errno.EBADFD) socket_checkerr(fd) else: end = time.time() + self.gettimeout() while True: if socket_connect(fd, address): return if time.time() >= end: raise socket.timeout("timed out") try: self._trampoline(fd, write=True, timeout=end - time.time(), timeout_exc=socket.timeout("timed out")) except IOClosed: # ... we need some workable errno here. raise socket.error(errno.EBADFD) socket_checkerr(fd)
def _get_fd(self, fh): try: return self.fds[fh] except KeyError: raise FuseOSError(EBADFD)
def release(self, path, fh): try: file = self.fds.pop(fh) file.flush() except KeyError: raise FuseOSError(EBADFD)
def connect_ex(self, address): if self.act_non_blocking: return self.fd.connect_ex(address) fd = self.fd if self.gettimeout() is None: while not socket_connect(fd, address): try: self._trampoline(fd, write=True) socket_checkerr(fd) except socket.error as ex: return get_errno(ex) except IOClosed: return errno.EBADFD else: end = time.time() + self.gettimeout() while True: try: if socket_connect(fd, address): return 0 if time.time() >= end: raise socket.timeout(errno.EAGAIN) self._trampoline(fd, write=True, timeout=end - time.time(), timeout_exc=socket.timeout(errno.EAGAIN)) socket_checkerr(fd) except socket.error as ex: return get_errno(ex) except IOClosed: return errno.EBADFD
def send(self) -> int: """Send outgoing data """ with self._write_lock: while len(self.outbuffer) > 0: try: sent = self.sock.send(self.outbuffer) self.outbuffer = self.outbuffer[sent:] except socket.error as error: if error.args[0] == errno.EAGAIN: time.sleep(0.1) elif error.args[0] in ( errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN, errno.ECONNABORTED, errno.EPIPE ): self.close() return 0 elif os.name == 'posix': # Windows doesn't seems to have EBADFD if sys.platform == 'darwin': # OS X uses EBADF as EBADFD. why? no idea asks Tim if error.args[0] == errno.EBADF: self.close() return 0 else: if error.args[0] == errno.EBADFD: self.close() return 0 raise else: raise
def connect(self, address): if self.act_non_blocking: return self.fd.connect(address) fd = self.fd _timeout_exc = socket_timeout('timed out') if self.gettimeout() is None: while not socket_connect(fd, address): try: self._trampoline(fd, write=True) except IOClosed: raise socket.error(errno.EBADFD) socket_checkerr(fd) else: end = time.time() + self.gettimeout() while True: if socket_connect(fd, address): return if time.time() >= end: raise _timeout_exc timeout = end - time.time() try: self._trampoline(fd, write=True, timeout=timeout, timeout_exc=_timeout_exc) except IOClosed: # ... we need some workable errno here. raise socket.error(errno.EBADFD) socket_checkerr(fd)
def connect_ex(self, address): if self.act_non_blocking: return self.fd.connect_ex(address) fd = self.fd if self.gettimeout() is None: while not socket_connect(fd, address): try: self._trampoline(fd, write=True) socket_checkerr(fd) except socket.error as ex: return get_errno(ex) except IOClosed: return errno.EBADFD else: end = time.time() + self.gettimeout() timeout_exc = socket.timeout(errno.EAGAIN) while True: try: if socket_connect(fd, address): return 0 if time.time() >= end: raise timeout_exc self._trampoline(fd, write=True, timeout=end - time.time(), timeout_exc=timeout_exc) socket_checkerr(fd) except socket.error as ex: return get_errno(ex) except IOClosed: return errno.EBADFD
def _consistent(self, cached): try: all_fh = [ ] for vlist in cached.open_handle.values(): all_fh += vlist for v_fh in all_fh: assert (None, v_fh) in self._shelfcache, 'Inconsistent list members' except Exception as e: self.logger.error('Shadow cache is corrupt: %s' % str(e)) if self.verbose > 3: set_trace() raise TmfsOSError(errno.EBADFD) # Most uses send an open handle fh (integer) as key. truncate by name # is the exception. An update needs to be reflected for all keys.