Python gevent.socket 模块,EWOULDBLOCK 实例源码

我们从Python开源项目中,提取了以下35个代码示例,用于说明如何使用gevent.socket.EWOULDBLOCK

项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def _do_accept(self, event, _evtype):
        assert event is self._accept_event
        for _ in xrange(self.max_accept):
            address = None
            try:
                if self.full():
                    self.stop_accepting()
                    return
                try:
                    client_socket, address = self.socket.accept()
                except socket.error, err:
                    if err[0] == EWOULDBLOCK:
                        return
                    raise
                self.delay = self.min_delay
                client_socket = socket.socket(_sock=client_socket)
                spawn = self._spawn
                if spawn is None:
                    self._handle(client_socket, address)
                else:
                    spawn(self._handle, client_socket, address)
            except:
                traceback.print_exc()
                ex = sys.exc_info()[1]
                if self.is_fatal_error(ex):
                    self.kill()
                    sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex)))
                    return
                try:
                    if address is None:
                        sys.stderr.write('%s: Failed.\n' % (self, ))
                    else:
                        sys.stderr.write('%s: Failed to handle request from %s\n' % (self, address, ))
                except Exception:
                    traceback.print_exc()
                if self.delay >= 0:
                    self.stop_accepting()
                    self._start_accepting_timer = core.timer(self.delay, self.start_accepting)
                    self.delay = min(self.max_delay, self.delay * 2)
                return
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def _do_accept(self, event, _evtype):
        assert event is self._accept_event
        for _ in xrange(self.max_accept):
            address = None
            try:
                if self.full():
                    self.stop_accepting()
                    return
                try:
                    client_socket, address = self.socket.accept()
                except socket.error, err:
                    if err[0] == EWOULDBLOCK:
                        return
                    raise
                self.delay = self.min_delay
                client_socket = socket.socket(_sock=client_socket)
                spawn = self._spawn
                if spawn is None:
                    self._handle(client_socket, address)
                else:
                    spawn(self._handle, client_socket, address)
            except:
                traceback.print_exc()
                ex = sys.exc_info()[1]
                if self.is_fatal_error(ex):
                    self.kill()
                    sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex)))
                    return
                try:
                    if address is None:
                        sys.stderr.write('%s: Failed.\n' % (self, ))
                    else:
                        sys.stderr.write('%s: Failed to handle request from %s\n' % (self, address, ))
                except Exception:
                    traceback.print_exc()
                if self.delay >= 0:
                    self.stop_accepting()
                    self._start_accepting_timer = core.timer(self.delay, self.start_accepting)
                    self.delay = min(self.max_delay, self.delay * 2)
                return
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def accept(self):
        """Accepts a new connection from a remote client, and returns
        a tuple containing that new connection wrapped with a server-side
        SSL channel, and the address of the remote client."""
        sock = self._sock
        while True:
            try:
                client_socket, address = sock.accept()
                break
            except socket_error as ex:
                if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
                    raise
                sys.exc_clear()
            self._wait(self._read_event)

        sslobj = SSLSocket(client_socket,
                           keyfile=self.keyfile,
                           certfile=self.certfile,
                           server_side=True,
                           cert_reqs=self.cert_reqs,
                           ssl_version=self.ssl_version,
                           ca_certs=self.ca_certs,
                           do_handshake_on_connect=self.do_handshake_on_connect,
                           suppress_ragged_eofs=self.suppress_ragged_eofs,
                           ciphers=self.ciphers)

        return sslobj, address
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def do_read(self):
            try:
                client_socket, address = self.socket.accept()
            except _socket.error as err:
                if err.args[0] == EWOULDBLOCK:
                    return
                raise
            sockobj = socket(_sock=client_socket)
            if PYPY:
                client_socket._drop()
            return sockobj, address
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error as err:
            if err.args[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
def accept(self):
        """Accepts a new connection from a remote client, and returns
        a tuple containing that new connection wrapped with a server-side
        SSL channel, and the address of the remote client."""
        sock = self._sock
        while True:
            try:
                client_socket, address = sock.accept()
                break
            except socket_error as ex:
                if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
                    raise
                sys.exc_clear()
            self._wait(self._read_event)

        sslobj = SSLSocket(client_socket,
                           keyfile=self.keyfile,
                           certfile=self.certfile,
                           server_side=True,
                           cert_reqs=self.cert_reqs,
                           ssl_version=self.ssl_version,
                           ca_certs=self.ca_certs,
                           do_handshake_on_connect=self.do_handshake_on_connect,
                           suppress_ragged_eofs=self.suppress_ragged_eofs,
                           ciphers=self.ciphers)

        return sslobj, address
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
def do_read(self):
            try:
                client_socket, address = self.socket.accept()
            except _socket.error as err:
                if err.args[0] == EWOULDBLOCK:
                    return
                raise
            sockobj = socket(_sock=client_socket)
            if PYPY:
                client_socket._drop()
            return sockobj, address
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error as err:
            if err.args[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def _do_accept(self, event, _evtype):
        assert event is self._accept_event
        for _ in xrange(self.max_accept):
            address = None
            try:
                if self.full():
                    self.stop_accepting()
                    return
                try:
                    client_socket, address = self.socket.accept()
                except socket.error, err:
                    if err[0] == EWOULDBLOCK:
                        return
                    raise
                self.delay = self.min_delay
                client_socket = socket.socket(_sock=client_socket)
                spawn = self._spawn
                if spawn is None:
                    self._handle(client_socket, address)
                else:
                    spawn(self._handle, client_socket, address)
            except:
                traceback.print_exc()
                ex = sys.exc_info()[1]
                if self.is_fatal_error(ex):
                    self.kill()
                    sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex)))
                    return
                try:
                    if address is None:
                        sys.stderr.write('%s: Failed.\n' % (self, ))
                    else:
                        sys.stderr.write('%s: Failed to handle request from %s\n' % (self, address, ))
                except Exception:
                    traceback.print_exc()
                if self.delay >= 0:
                    self.stop_accepting()
                    self._start_accepting_timer = core.timer(self.delay, self.start_accepting)
                    self.delay = min(self.max_delay, self.delay * 2)
                return
项目:Flask-SocketIO    作者:cutedogspark    | 项目源码 | 文件源码
def accept(self):
        """Accepts a new connection from a remote client, and returns
        a tuple containing that new connection wrapped with a server-side
        SSL channel, and the address of the remote client."""
        sock = self._sock
        while True:
            try:
                client_socket, address = sock.accept()
                break
            except socket_error, ex:
                if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
                    raise
                sys.exc_clear()
            self._wait(self._read_event)

        sslobj = SSLSocket(client_socket,
                           keyfile=self.keyfile,
                           certfile=self.certfile,
                           server_side=True,
                           cert_reqs=self.cert_reqs,
                           ssl_version=self.ssl_version,
                           ca_certs=self.ca_certs,
                           do_handshake_on_connect=self.do_handshake_on_connect,
                           suppress_ragged_eofs=self.suppress_ragged_eofs,
                           ciphers=self.ciphers)

        return sslobj, address
项目:Flask-SocketIO    作者:cutedogspark    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:Flask-SocketIO    作者:cutedogspark    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def accept(self):
        """Accepts a new connection from a remote client, and returns
        a tuple containing that new connection wrapped with a server-side
        SSL channel, and the address of the remote client."""
        sock = self._sock
        while True:
            try:
                client_socket, address = sock.accept()
                break
            except socket_error as ex:
                if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
                    raise
                sys.exc_clear()
            self._wait(self._read_event)

        sslobj = SSLSocket(client_socket,
                           keyfile=self.keyfile,
                           certfile=self.certfile,
                           server_side=True,
                           cert_reqs=self.cert_reqs,
                           ssl_version=self.ssl_version,
                           ca_certs=self.ca_certs,
                           do_handshake_on_connect=self.do_handshake_on_connect,
                           suppress_ragged_eofs=self.suppress_ragged_eofs,
                           ciphers=self.ciphers)

        return sslobj, address
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def do_read(self):
            try:
                client_socket, address = self.socket.accept()
            except _socket.error as err:
                if err.args[0] == EWOULDBLOCK:
                    return
                raise
            sockobj = socket(_sock=client_socket)
            if PYPY:
                client_socket._drop()
            return sockobj, address
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error as err:
            if err.args[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def do_read(self):
        try:
            client_socket, address = self.socket.accept()
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return socket(_sock=client_socket), address
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error, err:
            if err[0] == EWOULDBLOCK:
                return
            raise
        return data, address
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def _do_accept(self, event, _evtype):
        assert event is self._accept_event
        for _ in xrange(self.max_accept):
            address = None
            try:
                if self.full():
                    self.stop_accepting()
                    return
                try:
                    client_socket, address = self.socket.accept()
                except socket.error, err:
                    if err[0] == EWOULDBLOCK:
                        return
                    raise
                self.delay = self.min_delay
                client_socket = socket.socket(_sock=client_socket)
                spawn = self._spawn
                if spawn is None:
                    self._handle(client_socket, address)
                else:
                    spawn(self._handle, client_socket, address)
            except:
                traceback.print_exc()
                ex = sys.exc_info()[1]
                if self.is_fatal_error(ex):
                    self.kill()
                    sys.stderr.write('ERROR: %s failed with %s\n' % (self, str(ex) or repr(ex)))
                    return
                try:
                    if address is None:
                        sys.stderr.write('%s: Failed.\n' % (self, ))
                    else:
                        sys.stderr.write('%s: Failed to handle request from %s\n' % (self, address, ))
                except Exception:
                    traceback.print_exc()
                if self.delay >= 0:
                    self.stop_accepting()
                    self._start_accepting_timer = core.timer(self.delay, self.start_accepting)
                    self.delay = min(self.max_delay, self.delay * 2)
                return
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def accept(self):
        """Accepts a new connection from a remote client, and returns
        a tuple containing that new connection wrapped with a server-side
        SSL channel, and the address of the remote client."""
        sock = self._sock
        while True:
            try:
                client_socket, address = sock.accept()
                break
            except socket_error as ex:
                if ex.args[0] != EWOULDBLOCK or self.timeout == 0.0:
                    raise
                sys.exc_clear()
            self._wait(self._read_event)

        sslobj = SSLSocket(client_socket,
                           keyfile=self.keyfile,
                           certfile=self.certfile,
                           server_side=True,
                           cert_reqs=self.cert_reqs,
                           ssl_version=self.ssl_version,
                           ca_certs=self.ca_certs,
                           do_handshake_on_connect=self.do_handshake_on_connect,
                           suppress_ragged_eofs=self.suppress_ragged_eofs,
                           ciphers=self.ciphers)

        return sslobj, address
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def do_read(self):
            try:
                client_socket, address = self.socket.accept()
            except _socket.error as err:
                if err.args[0] == EWOULDBLOCK:
                    return
                raise
            sockobj = socket(_sock=client_socket)
            if PYPY:
                client_socket._drop()
            return sockobj, address
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def do_read(self):
        try:
            data, address = self._socket.recvfrom(8192)
        except _socket.error as err:
            if err.args[0] == EWOULDBLOCK:
                return
            raise
        return data, address