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


Python errno.ENOTCONN屬性代碼示例

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


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

示例1: deliver_dnotify

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def deliver_dnotify(self, dnstring, _recurse = 0):
        if self.s == None:
            self.connect()
        if _recurse > _MAX_RECURSE:
            raise Exception('Cannot reconnect: %s', self.spath)
        if not dnstring.endswith('\n'):
            dnstring += '\n'
        while True:
            try:
                self.s.send(dnstring)
                break
            except socket.error as why:
                if why[0] == EINTR:
                    continue
                elif why[0] in (EPIPE, ENOTCONN, ECONNRESET):
                    self.s = None
                    return self.deliver_dnotify(dnstring, _recurse + 1)
                raise why
        # Clean any incoming data on the socket
        if len(self.poller.poll(0)) > 0:
            try:
                self.s.recv(1024)
            except:
                pass
        return 
開發者ID:sippy,項目名稱:rtp_cluster,代碼行數:27,代碼來源:DNRelay.py

示例2: __init__

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def __init__(self, server, conn, addr):
        asynchat.async_chat.__init__(self, conn)
        self.__server = server
        self.__conn = conn
        self.__addr = addr
        self.__line = []
        self.__state = self.COMMAND
        self.__greeting = 0
        self.__mailfrom = None
        self.__rcpttos = []
        self.__data = ''
        self.__fqdn = socket.getfqdn()
        try:
            self.__peer = conn.getpeername()
        except socket.error, err:
            # a race condition  may occur if the other end is closing
            # before we can get the peername
            self.close()
            if err[0] != errno.ENOTCONN:
                raise
            return 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:23,代碼來源:smtpd.py

示例3: send

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def send(self, message, flags):
        with self.send_token:
            if not self.state.ESTABLISHED:
                self.err("send() in socket state {0}".format(self.state))
                if self.state.CLOSE_WAIT:
                    raise err.Error(errno.EPIPE)
                raise err.Error(errno.ENOTCONN)
            if len(message) > self.send_miu:
                raise err.Error(errno.EMSGSIZE)
            while self.send_window_slots == 0 and self.state.ESTABLISHED:
                if flags & nfc.llcp.MSG_DONTWAIT:
                    raise err.Error(errno.EWOULDBLOCK)
                self.log("waiting on busy send window")
                self.send_token.wait()
            self.log("send {0} byte on {1}".format(len(message), str(self)))
            if self.state.ESTABLISHED:
                send_pdu = pdu.Information(self.peer, self.addr, data=message)
                send_pdu.ns = self.send_cnt
                self.send_cnt = (self.send_cnt + 1) % 16
                super(DataLinkConnection, self).send(send_pdu, flags)
            return self.state.ESTABLISHED is True 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:23,代碼來源:tco.py

示例4: recv

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def recv(self):
        with self.lock:
            if not (self.state.ESTABLISHED or self.state.CLOSE_WAIT):
                self.err("recv() in socket state {0}".format(self.state))
                raise err.Error(errno.ENOTCONN)

            try:
                rcvd_pdu = super(DataLinkConnection, self).recv()
            except IndexError:
                return None

            if rcvd_pdu.name == "I":
                self.recv_confs += 1
                if self.recv_confs > self.recv_win:
                    self.err("recv_confs({0}) > recv_win({1})"
                             .format(self.recv_confs, self.recv_win))
                    raise RuntimeError("recv_confs > recv_win")
                return rcvd_pdu.data

            if rcvd_pdu.name == "DISC":
                self.close()
                return None

            raise RuntimeError("only I or DISC expected, not " + rcvd_pdu.name) 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:26,代碼來源:tco.py

示例5: _sock_connect_tfo

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def _sock_connect_tfo(self, fut, sock, address, dat):
        fd = sock.fileno()
        try:
            sent = sock.sendto(dat, MSG_FASTOPEN, address)
        except (BlockingIOError, InterruptedError):
            # no data sent! deal with it using sock_sendall
            # happen when fallback to 3-way handshake
            fut.add_done_callback(lambda _: self.remove_writer(fd))
            self.add_writer(fd, self._sock_connect_tfo_cb, fut, sock, address, dat)
        except Exception as exc:
            if isinstance(exc, OSError) and exc.errno == errno.ENOTCONN:
                fut.set_exception(RuntimeError('TCP Fast Open unavailable'))
            else:
                fut.set_exception(exc)
        else:
            if sent == len(dat):
                fut.set_result(None)
            else:
                # meaningless because too large data can't fit into the TCP SYN packet
                # or will it happen even when data can fit?
                # just keep consistency with fallback situation
                self._sock_sendall(fut, False, sock, dat[sent:]) 
開發者ID:krrr,項目名稱:wstan,代碼行數:24,代碼來源:linux.py

示例6: _remove_connection

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def _remove_connection(self, fdesc):
        """
        Unregister, close and remove inbound connection with given fd.

        :param fdesc: File descriptor of connection to be removed.
        :type fdesc: ``int``
        """
        self._pobj.unregister(fdesc)
        try:
            self._conndetails_by_fd[fdesc].connection.shutdown(
                socket.SHUT_RDWR
            )
        except socket.error as serr:
            if serr.errno != errno.ENOTCONN:
                raise
                # Else, client already closed the connection.
        self._conndetails_by_fd[fdesc].connection.close()

        name = self._conndetails_by_fd[fdesc].name
        del self._conndetails_by_fd[fdesc]
        if name in self._conndetails_by_name:
            del self._conndetails_by_name[name] 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:24,代碼來源:server.py

示例7: close

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def close(self):
        """Close the connection without assuming anything about it."""
        try:
            file = self.file
            self.file = None
            if file is not None:
                file.close()
        finally:
            sock = self.sock
            self.sock = None
            if sock is not None:
                try:
                    sock.shutdown(socket.SHUT_RDWR)
                except OSError as e:
                    # The server might already have closed the connection
                    if e.errno != errno.ENOTCONN:
                        raise
                finally:
                    sock.close()

    #__del__ = quit


    # optional commands: 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:26,代碼來源:poplib.py

示例8: shutdown

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def shutdown(self):
        if self.wthr == None:
            return
        self.wthr.shutdown()
        try:
            self.clientsock.shutdown(socket.SHUT_RDWR)
        except Exception as e:
            if not isinstance(e, socket.error) or e.errno != ENOTCONN:
                dump_exception('self.clientsock.shutdown(socket.SHUT_RDWR)')
        self.clientsock.close()
        self.wthr = None
        self.rthr = None 
開發者ID:sippy,項目名稱:rtp_cluster,代碼行數:14,代碼來源:CLIManager.py

示例9: send_raw

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def send_raw(self, command, _recurse = 0, stime = None):
        if _recurse > _MAX_RECURSE:
            raise Exception('Cannot reconnect: %s' % (str(self.userv.address),))
        if self.s == None:
            self.connect()
        #print('%s.send_raw(%s)' % (id(self), command))
        if stime == None:
            stime = MonoTime()
        while True:
            try:
                self.s.send(command.encode())
                break
            except socket.error as why:
                if why.errno == EINTR:
                    continue
                elif why.errno in (EPIPE, ENOTCONN, ECONNRESET):
                    self.s = None
                    return self.send_raw(command, _recurse + 1, stime)
                raise why
        while True:
            try:
                rval = self.s.recv(1024)
                if len(rval) == 0:
                    self.s = None
                    return self.send_raw(command, _MAX_RECURSE, stime)
                rval = rval.decode().strip()
                break
            except socket.error as why:
                if why.errno == EINTR:
                    continue
                elif why.errno in (EPIPE, ENOTCONN, ECONNRESET):
                    self.s = None
                    return self.send_raw(command, _recurse + 1, stime)
                raise why
        rtpc_delay = stime.offsetFromNow()
        return (rval, rtpc_delay) 
開發者ID:sippy,項目名稱:rtp_cluster,代碼行數:38,代碼來源:Rtp_proxy_client_stream.py

示例10: proxy_protocol_access_check

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def proxy_protocol_access_check(self):
        # check in allow list
        if isinstance(self.unreader, SocketUnreader):
            try:
                remote_host = self.unreader.sock.getpeername()[0]
            except socket.error as e:
                if e.args[0] == ENOTCONN:
                    raise ForbiddenProxyRequest("UNKNOW")
                raise
            if ("*" not in self.cfg.proxy_allow_ips and
                    remote_host not in self.cfg.proxy_allow_ips):
                raise ForbiddenProxyRequest(remote_host) 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:message.py

示例11: _handle_stage_connecting

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def _handle_stage_connecting(self, data):
        if self._is_local:
            data = self._encryptor.encrypt(data)
        self._data_to_write_to_remote.append(data)
        if self._is_local and not self._fastopen_connected and \
                self._config['fast_open']:
            # for sslocal and fastopen, we basically wait for data and use
            # sendto to connect
            try:
                # only connect once
                self._fastopen_connected = True
                remote_sock = \
                    self._create_remote_socket(self._chosen_server[0],
                                               self._chosen_server[1])
                self._loop.add(remote_sock, eventloop.POLL_ERR, self._server)
                data = b''.join(self._data_to_write_to_remote)
                l = len(data)
                s = remote_sock.sendto(data, MSG_FASTOPEN, self._chosen_server)
                if s < l:
                    data = data[s:]
                    self._data_to_write_to_remote = [data]
                else:
                    self._data_to_write_to_remote = []
                self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
            except (OSError, IOError) as e:
                if eventloop.errno_from_exception(e) == errno.EINPROGRESS:
                    # in this case data is not sent at all
                    self._update_stream(STREAM_UP, WAIT_STATUS_READWRITING)
                elif eventloop.errno_from_exception(e) == errno.ENOTCONN:
                    logging.error('fast open not supported on this OS')
                    self._config['fast_open'] = False
                    self.destroy()
                else:
                    shell.print_exception(e)
                    if self._config['verbose']:
                        traceback.print_exc()
                    self.destroy() 
開發者ID:ntfreedom,項目名稱:neverendshadowsocks,代碼行數:39,代碼來源:tcprelay.py

示例12: shutdown

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def shutdown(self):
        """Close I/O established in "open"."""
        self.file.close()
        try:
            self.sock.shutdown(socket.SHUT_RDWR)
        except socket.error as e:
            # The server might already have closed the connection
            if e.errno != errno.ENOTCONN:
                raise
        finally:
            self.sock.close() 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:13,代碼來源:imaplib.py

示例13: __init__

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def __init__(self, sock, keyfile=None, certfile=None,
                 server_side=False, cert_reqs=CERT_NONE,
                 ssl_version=PROTOCOL_SSLv23, ca_certs=None,
                 do_handshake_on_connect=True,
                 suppress_ragged_eofs=True, ciphers=None):
        socket.__init__(self, _sock=sock._sock)
        # The initializer for socket overrides the methods send(), recv(), etc.
        # in the instancce, which we don't need -- but we want to provide the
        # methods defined in SSLSocket.
        for attr in _delegate_methods:
            try:
                delattr(self, attr)
            except AttributeError:
                pass

        if certfile and not keyfile:
            keyfile = certfile
        # see if it's connected
        try:
            socket.getpeername(self)
        except socket_error, e:
            if e.errno != errno.ENOTCONN:
                raise
            # no, no connection yet
            self._connected = False
            self._sslobj = None 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:28,代碼來源:ssl.py

示例14: ensure_connection

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def ensure_connection(self):
        if self.is_connected:
            return
        raise NSQSocketError(ENOTCONN, 'Socket is not connected') 
開發者ID:wtolson,項目名稱:gnsq,代碼行數:6,代碼來源:stream.py

示例15: shutdown

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENOTCONN [as 別名]
def shutdown(self):
        """Close I/O established in "open"."""
        self.file.close()
        try:
            self.sock.shutdown(socket.SHUT_RDWR)
        except socket.error as e:
            # The server might already have closed the connection.
            # On Windows, this may result in WSAEINVAL (error 10022):
            # An invalid operation was attempted.
            if e.errno not in (errno.ENOTCONN, 10022):
                raise
        finally:
            self.sock.close() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:imaplib.py


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