parameters: (self)
docstring: Read each request and respond appropriately.
docstring_summary: Read each request and respond appropriately.
docstring_tokens: Read each request and respond appropriately .
function: def communicate(self):
          """Read each request and respond appropriately."""
          request_seen = False
          try:
              while True:
                  # (re)set req to None so that if something goes wrong in
                  # the RequestHandlerClass constructor, the error doesn't
                  # get written to the previous request.
                  req = None
                  req = self.RequestHandlerClass(self.server, self)
  
                  # This order of operations should guarantee correct pipelining.
                  req.parse_request()
                  if self.server.stats['Enabled']:
                      self.requests_seen += 1
                  if not req.ready:
                      # Something went wrong in the parsing (and the server has
                      # probably already made a simple_response). Return and
                      # let the conn close.
                      return
  
                  request_seen = True
                  req.respond()
                  if req.close_connection:
                      return
          except socket.error as ex:
              errnum = ex.args[0]
              # sadly SSL sockets return a different (longer) time out string
              timeout_errs = 'timed out', 'The read operation timed out'
              if errnum in timeout_errs:
                  # Don't error if we're between requests; only error
                  # if 1) no request has been started at all, or 2) we're
                  # in the middle of a request.
                  # See https://github.com/cherrypy/cherrypy/issues/853
                  if (not request_seen) or (req and req.started_request):
                      self._conditional_error(req, '408 Request Timeout')
              elif errnum not in errors.socket_errors_to_ignore:
                  self.server.error_log('socket.error %s' % repr(errnum),
                                        level=logging.WARNING, traceback=True)
                  self._conditional_error(req, '500 Internal Server Error')
          except (KeyboardInterrupt, SystemExit):
              raise
          except errors.FatalSSLAlert:
              pass
          except errors.NoSSLError:
              self._handle_no_ssl(req)
          except Exception as ex:
              self.server.error_log(
                  repr(ex), level=logging.ERROR, traceback=True)
              self._conditional_error(req, '500 Internal Server Error')
function_tokens: def communicate ( self ) : request_seen = False try : while True : # (re)set req to None so that if something goes wrong in # the RequestHandlerClass constructor, the error doesn't # get written to the previous request. req = None req = self . RequestHandlerClass ( self . server , self ) # This order of operations should guarantee correct pipelining. req . parse_request ( ) if self . server . stats [ 'Enabled' ] : self . requests_seen += 1 if not req . ready : # Something went wrong in the parsing (and the server has # probably already made a simple_response). Return and # let the conn close. return request_seen = True req . respond ( ) if req . close_connection : return except socket . error as ex : errnum = ex . args [ 0 ] # sadly SSL sockets return a different (longer) time out string timeout_errs = 'timed out' , 'The read operation timed out' if errnum in timeout_errs : # Don't error if we're between requests; only error # if 1) no request has been started at all, or 2) we're # in the middle of a request. # See https://github.com/cherrypy/cherrypy/issues/853 if ( not request_seen ) or ( req and req . started_request ) : self . _conditional_error ( req , '408 Request Timeout' ) elif errnum not in errors . socket_errors_to_ignore : self . server . error_log ( 'socket.error %s' % repr ( errnum ) , level = logging . WARNING , traceback = True ) self . _conditional_error ( req , '500 Internal Server Error' ) except ( KeyboardInterrupt , SystemExit ) : raise except errors . FatalSSLAlert : pass except errors . NoSSLError : self . _handle_no_ssl ( req ) except Exception as ex : self . server . error_log ( repr ( ex ) , level = logging . ERROR , traceback = True ) self . _conditional_error ( req , '500 Internal Server Error' )