MCPcopy Index your code
hub / github.com/python/cpython / handle_request

Method handle_request

Lib/socketserver.py:273–300  ·  view source on GitHub ↗

Handle one request, possibly blocking. Respects self.timeout.

(self)

Source from the content-addressed store, hash-verified

271 # constructor will handle the request all by itself
272
273 def handle_request(self):
274 """Handle one request, possibly blocking.
275
276 Respects self.timeout.
277 """
278 # Support people who used socket.settimeout() to escape
279 # handle_request before self.timeout was available.
280 timeout = self.socket.gettimeout()
281 if timeout is None:
282 timeout = self.timeout
283 elif self.timeout is not None:
284 timeout = min(timeout, self.timeout)
285 if timeout is not None:
286 deadline = time() + timeout
287
288 # Wait until a request arrives or the timeout expires - the loop is
289 # necessary to accommodate early wakeups due to EINTR.
290 with _ServerSelector() as selector:
291 selector.register(self, selectors.EVENT_READ)
292
293 while True:
294 if selector.select(timeout):
295 return self._handle_request_noblock()
296 else:
297 if timeout is not None:
298 timeout = deadline - time()
299 if timeout < 0:
300 return self.handle_timeout()
301
302 def _handle_request_noblock(self):
303 """Handle one request, without blocking.

Callers 1

serve_until_quitMethod · 0.45

Calls 6

handle_timeoutMethod · 0.95
timeClass · 0.90
gettimeoutMethod · 0.45
registerMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected