MCPcopy Index your code
hub / github.com/microsoft/playwright-python / _handle_internal

Method _handle_internal

playwright/_impl/_helper.py:448–472  ·  view source on GitHub ↗
(self, route: "Route")

Source from the content-addressed store, hash-verified

446 self._active_invocations.remove(handler_invocation)
447
448 async def _handle_internal(self, route: "Route") -> bool:
449 handled_future = route._start_handling()
450
451 self._handled_count += 1
452 if self._is_sync:
453 handler_finished_future = route._loop.create_future()
454
455 def _handler() -> None:
456 try:
457 self.handler(route, route.request) # type: ignore
458 handler_finished_future.set_result(None)
459 except Exception as e:
460 handler_finished_future.set_exception(e)
461
462 # As with event handlers, each route handler is a potentially blocking context
463 # so it needs a fiber.
464 g = RouteGreenlet(_handler)
465 g.switch()
466 await handler_finished_future
467 else:
468 coro_or_future = self.handler(route, route.request) # type: ignore
469 if coro_or_future:
470 # separate task so that we get a proper stack trace for exceptions / tracing api_name extraction
471 await asyncio.ensure_future(coro_or_future)
472 return await handled_future
473
474 async def stop(self, behavior: Literal["ignoreErrors", "wait"]) -> None:
475 # When a handler is manually unrouted or its page/context is closed we either

Callers 1

handleMethod · 0.95

Calls 2

RouteGreenletClass · 0.90
_start_handlingMethod · 0.80

Tested by

no test coverage detected