MCPcopy Index your code
hub / github.com/RustPython/RustPython / handle_request

Method handle_request

Lib/socketserver.py:276–303  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

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

Callers 1

serve_until_quitMethod · 0.45

Calls 7

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

Tested by

no test coverage detected