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

Method _on_locator_handler_triggered

playwright/_impl/_page.py:1422–1460  ·  view source on GitHub ↗
(self, uid: str)

Source from the content-addressed store, hash-verified

1420 )
1421
1422 async def _on_locator_handler_triggered(self, uid: str) -> None:
1423 remove = False
1424 try:
1425 handler = self._locator_handlers.get(uid)
1426 if handler and handler.times != 0:
1427 if handler.times is not None:
1428 handler.times -= 1
1429 if self._dispatcher_fiber:
1430 handler_finished_future = self._loop.create_future()
1431
1432 def _handler() -> None:
1433 try:
1434 handler()
1435 handler_finished_future.set_result(None)
1436 except Exception as e:
1437 handler_finished_future.set_exception(e)
1438
1439 g = LocatorHandlerGreenlet(_handler)
1440 g.switch()
1441 await handler_finished_future
1442 else:
1443 coro_or_future = handler()
1444 if coro_or_future:
1445 await coro_or_future
1446 remove = handler.times == 0
1447 finally:
1448 if remove:
1449 del self._locator_handlers[uid]
1450 try:
1451 await self._connection.wrap_api_call(
1452 lambda: self._channel.send(
1453 "resolveLocatorHandlerNoReply",
1454 None,
1455 {"uid": uid, "remove": remove},
1456 ),
1457 is_internal=True,
1458 )
1459 except Error:
1460 pass
1461
1462 async def remove_locator_handler(self, locator: "Locator") -> None:
1463 for uid, data in self._locator_handlers.copy().items():

Callers 1

__init__Method · 0.95

Calls 5

wrap_api_callMethod · 0.80
handlerFunction · 0.50
getMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected