MCPcopy
hub / github.com/microsoft/playwright-python / handle

Method handle

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

Source from the content-addressed store, hash-verified

422 return url_matches(self._base_url, request_url, self.url)
423
424 async def handle(self, route: "Route") -> bool:
425 handler_invocation = RouteHandlerInvocation(
426 asyncio.get_running_loop().create_future(), route
427 )
428 self._active_invocations.add(handler_invocation)
429 try:
430 return await self._handle_internal(route)
431 except Exception as e:
432 # If the handler was stopped (without waiting for completion), we ignore all exceptions.
433 if self._ignore_exception:
434 return False
435 if is_target_closed_error(e):
436 # We are failing in the handler because the target has closed.
437 # Give user a hint!
438 optional_async_prefix = "await " if not self._is_sync else ""
439 raise rewrite_error(
440 e,
441 f"\"{str(e)}\" while running route callback.\nConsider awaiting `{optional_async_prefix}page.unroute_all(behavior='ignoreErrors')`\nbefore the end of the test to ignore remaining routes in flight.",
442 )
443 raise e
444 finally:
445 handler_invocation.complete.set_result(None)
446 self._active_invocations.remove(handler_invocation)
447
448 async def _handle_internal(self, route: "Route") -> bool:
449 handled_future = route._start_handling()

Callers 4

_on_routeMethod · 0.45
_on_web_socket_routeMethod · 0.45
_on_routeMethod · 0.45
_on_web_socket_routeMethod · 0.45

Calls 4

_handle_internalMethod · 0.95
is_target_closed_errorFunction · 0.90
rewrite_errorFunction · 0.90

Tested by

no test coverage detected