我们从Python开源项目中,提取了以下35个代码示例,用于说明如何使用gevent.socket.EWOULDBLOCK。
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
def do_read(self): try: data, address = self._socket.recvfrom(8192) except _socket.error, err: if err[0] == EWOULDBLOCK: return raise return data, address
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
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
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
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
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