예제 #1
0
 def _accept_connection(self, protocol_factory, sock,
                        sslcontext=None, server=None):
     try:
         conn, addr = wrap_error(sock.accept())
         conn.setblocking(False)
     except (BlockingIOError, InterruptedError, ConnectionAbortedError):
         pass  # False alarm.
     except OSError as exc:
         # There's nowhere to send the error, so just log it.
         # TODO: Someone will want an error handler for this.
         if exc.errno in (errno.EMFILE, errno.ENFILE,
                          errno.ENOBUFS, errno.ENOMEM):
             # Some platforms (e.g. Linux keep reporting the FD as
             # ready, so we remove the read handler temporarily.
             # We'll try again in a while.
             logger.exception('Accept out of system resource (%s)', exc)
             self.remove_reader(sock.fileno())
             self.call_later(constants.ACCEPT_RETRY_DELAY,
                             self._start_serving,
                             protocol_factory, sock, sslcontext, server)
         else:
             raise  # The event loop will catch, log and ignore it.
     else:
         if sslcontext:
             self._make_ssl_transport(
                 conn, protocol_factory(), sslcontext, None,
                 server_side=True, extra={'peername': addr}, server=server)
         else:
             self._make_socket_transport(
                 conn, protocol_factory(), extra={'peername': addr},
                 server=server)
예제 #2
0
 def _maybe_resume_protocol(self):
     if (self._protocol_paused and
         self.get_write_buffer_size() <= self._low_water):
         self._protocol_paused = False
         try:
             self._protocol.resume_writing()
         except Exception:
             logger.exception('resume_writing() failed')
예제 #3
0
 def _maybe_pause_protocol(self):
     size = self.get_write_buffer_size()
     if size <= self._high_water:
         return
     if not self._protocol_paused:
         self._protocol_paused = True
         try:
             self._protocol.pause_writing()
         except Exception:
             logger.exception('pause_writing() failed')
예제 #4
0
 def _fatal_error(self, exc):
     # should be called by exception handler only
     if not isinstance(exc, (BrokenPipeError, ConnectionResetError)):
         logger.exception('Fatal error for %s', self)
     self._close(exc)
예제 #5
0
 def _fatal_error(self, exc):
     # should be called by exception handler only
     if not (isinstance(exc, OSError) and exc.errno == errno.EIO):
         logger.exception('Fatal error for %s', self)
     self._close(exc)
예제 #6
0
 def _fatal_error(self, exc):
     # Should be called from exception handler only.
     if not isinstance(exc, (BrokenPipeError, ConnectionResetError)):
         logger.exception('Fatal error for %s', self)
     self._force_close(exc)
예제 #7
0
 def _fatal_error(self, exc):
     # should be called by exception handler only
     if not (isinstance(exc, OSError) and exc.errno == errno.EIO):
         logger.exception('Fatal error for %s', self)
     self._close(exc)