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

Method _race_with_page_close

playwright/_impl/_network.py:549–565  ·  view source on GitHub ↗
(self, future: Coroutine)

Source from the content-addressed store, hash-verified

547 )
548
549 async def _race_with_page_close(self, future: Coroutine) -> None:
550 fut = asyncio.create_task(future)
551 # Rewrite the user's stack to the new task which runs in the background.
552 setattr(
553 fut,
554 "__pw_stack__",
555 getattr(asyncio.current_task(self._loop), "__pw_stack__", inspect.stack(0)),
556 )
557 target_closed_future = self.request._target_closed_future()
558 await asyncio.wait(
559 [fut, target_closed_future],
560 return_when=asyncio.FIRST_COMPLETED,
561 )
562 if fut.done() and fut.exception():
563 raise cast(BaseException, fut.exception())
564 if target_closed_future.done():
565 await asyncio.gather(fut, return_exceptions=True)
566
567
568def _create_task_and_ignore_exception(

Callers 4

abortMethod · 0.95
_inner_fulfillMethod · 0.95
_inner_continueMethod · 0.95

Calls 2

stackMethod · 0.80
_target_closed_futureMethod · 0.80

Tested by

no test coverage detected