MCPcopy
hub / github.com/benoitc/gunicorn / handle

Method handle

gunicorn/workers/sync.py:134–166  ·  view source on GitHub ↗
(self, listener, client, addr)

Source from the content-addressed store, hash-verified

132 self.run_for_one(timeout)
133
134 def handle(self, listener, client, addr):
135 req = None
136 try:
137 if self.cfg.is_ssl:
138 client = sock.ssl_wrap_socket(client, self.cfg)
139 parser = http.get_parser(self.cfg, client, addr)
140 req = next(parser)
141 self.handle_request(listener, req, client, addr)
142 except http.errors.NoMoreData as e:
143 self.log.debug("Ignored premature client disconnection. %s", e)
144 except StopIteration as e:
145 self.log.debug("Closing connection. %s", e)
146 except ssl.SSLError as e:
147 if e.args[0] == ssl.SSL_ERROR_EOF:
148 self.log.debug("ssl connection closed")
149 client.close()
150 else:
151 self.log.debug("Error processing SSL request.")
152 self.handle_error(req, client, addr, e)
153 except OSError as e:
154 if e.errno not in (errno.EPIPE, errno.ECONNRESET, errno.ENOTCONN):
155 self.log.exception("Socket error processing request.")
156 else:
157 if e.errno == errno.ECONNRESET:
158 self.log.debug("Ignoring connection reset")
159 elif e.errno == errno.ENOTCONN:
160 self.log.debug("Ignoring socket not connected")
161 else:
162 self.log.debug("Ignoring EPIPE")
163 except BaseException as e:
164 self.handle_error(req, client, addr, e)
165 finally:
166 util.close_graceful(client)
167
168 def handle_request(self, listener, req, client, addr):
169 environ = {}

Calls 5

handle_requestMethod · 0.95
handle_errorMethod · 0.80
debugMethod · 0.45
closeMethod · 0.45
exceptionMethod · 0.45