juggler: a page that is being built waits at most 30 s for the gate of the events, and says it when it does not get it (DRAFT, 0.51.1)
From the reading of 15d1891 by repos-6b: the construction of a page waited for the gate with no bound, a new dependency on the reader. It now
builds without the gate after 30 s and warns. wrapper.unit.page 71 -> 72.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
15d18917ec
commit
87a4e3b990
3 files changed
+38
-2
No files matched your search
@@ -7,5 +7,5 @@
|
||||
{"id": "wrapper.e2e.realness", "giro": "G2", "os": ["linux", "windows"], "min_tests": 32, "exact": true, "tests": ["tests/test_realness_behind_a_declared_exit_e2e.py"], "marker": "e2e", "needs_root": ["linux"], "note": "The realness check without a real proxy: six declared exits, the values a page reads, and the roads. Linux runs as root without xdist like the DoH suite (the resolver trap); on Windows the trap does not exist and the assertion on the system resolver is the only one omitted."},
|
||||
{"id": "wrapper.unit.udp", "giro": "G1", "os": ["linux", "windows"], "min_tests": 219, "exact": true, "tests": ["tests/test_a_served_launch_cannot_turn_the_launch_counter_off.py", "tests/test_the_witness_picks_a_port_both_sockets_bind.py", "tests/test_preload_newtab_reaches_the_core_only_when_asked.py", "tests/test_the_resolver_trap_counts_its_own_users.py", "tests/test_the_doh_e2e_launch_on_a_virtual_display.py", "tests/test_the_realness_helpers.py", "tests/test_the_h3_line_helpers.py", "tests/test_the_fake_doh_delays_and_refuses.py", "tests/test_the_host_address_helper.py", "tests/test_the_udp_chain_helper.py", "tests/test_the_fake_doh_answers.py", "tests/test_doh_session_prefs_unit.py", "tests/test_the_leak_watcher_sees_a_direct_connection.py", "tests/test_the_http_proxy_helper_asks_for_credentials.py", "tests/test_every_route_command_is_answered_may_fail.py", "tests/test_the_network_declaration_reaches_the_engine.py", "tests/test_the_resolver_trap_is_required_by_the_gate.py", "tests/test_the_exit_of_a_context_is_discovered_through_its_own_gateway.py", "tests/test_the_witness_hears_a_direct_send.py"], "marker": "unit", "needs_root": false, "note": "92 = 6+32+21+7+8+3+9+6. The leak watcher file defines exactly one of its two resolver-trap tests per host (7 everywhere), so no test is skipped. `exact`: min_tests is raised by hand when a test is added."},
|
||||
{"id": "wrapper.e2e.page", "giro": "G2", "os": ["linux", "windows"], "min_tests": 115, "exact": true, "tests": ["tests/test_a_tiny_download_on_a_served_browser_is_saved_e2e.py", "tests/test_a_page_that_moves_on_e2e.py", "tests/test_a_popup_is_reported_when_the_engine_says_it_is_ready_as_playwright_does_e2e.py", "tests/test_a_popup_of_a_link_reaches_the_client_e2e.py", "tests/test_popup_destinations_e2e.py", "tests/test_popups_reach_the_client_e2e.py", "tests/test_route_superseded_e2e.py"], "marker": "e2e", "needs_root": false, "note": "114 = 100 + the 14 of test_a_page_that_moves_on_e2e.py (a navigation the page overtook with location.replace ends; the engine fix 860ef8a6d9 is proved by it). 100 counted at the collection; was 96 = 10+32+16+34+4 before the popup tests of 6200bc2). A page is handed over when the engine says Page.ready; a popup reaches the client (link, noopener, window.open; own site and another; with and without a route; in-process and over launch_server) as Playwright's does; a superseded route. Needs the candidate binary, and the stock Playwright client of the dev extra."},
|
||||
{"id": "wrapper.unit.page", "giro": "G1", "os": ["linux", "windows"], "min_tests": 71, "exact": true, "tests": ["tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_page_number_follows_the_call.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_the_hand_over_of_a_popup_holds_under_concurrency.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py"], "marker": "unit", "needs_root": false, "note": "71 = 44 + 3+9+5+1+9 of the popup hand-over (24 counted at the collection before; was 20 = 3+8+1+8 before 6200bc2). The page dispatcher's wait for Page.ready and what it hands over; the drive gate goes through the core (the engine waits for the session's road)."}
|
||||
{"id": "wrapper.unit.page", "giro": "G1", "os": ["linux", "windows"], "min_tests": 72, "exact": true, "tests": ["tests/test_a_download_finished_before_it_was_announced_is_finished.py", "tests/test_every_order_of_the_events_of_a_popup_gives_one_page_event.py", "tests/test_ci_drive_gate_goes_through_the_core.py", "tests/test_a_page_is_handed_over_only_when_the_engine_says_it_is_ready.py", "tests/test_a_new_page_waits_for_the_engine.py", "tests/test_page_number_follows_the_call.py", "tests/test_a_commit_at_any_point_of_the_hand_over_reaches_the_client_once.py", "tests/test_no_event_of_any_family_is_lost_by_the_hand_over.py", "tests/test_the_hand_over_of_a_popup_holds_under_concurrency.py", "tests/test_a_page_closed_before_its_announcement_is_not_announced.py", "tests/test_a_live_event_does_not_overtake_the_replay_of_a_new_page.py"], "marker": "unit", "needs_root": false, "note": "72 = 44 + 3+9+5+1+10 of the popup hand-over (24 counted at the collection before; was 20 = 3+8+1+8 before 6200bc2). The page dispatcher's wait for Page.ready and what it hands over; the drive gate goes through the core (the engine waits for the session's road)."}
|
||||
]
|
||||
@@ -4784,6 +4784,8 @@ class BrowserDispatcher(Dispatcher):
|
||||
|
||||
#: How long the engine's reader waits for the gate of the events before it delivers the event anyway (see `events_gate`).
|
||||
GATE_WAIT_S = 5.0
|
||||
#: How long a page that is being built waits for the gate before it is built without it.
|
||||
PAGE_GATE_WAIT_S = 30.0
|
||||
|
||||
def __init__(self, server, browser_type: "BrowserTypeDispatcher",
|
||||
conn: Any, version: str, session_seed: Any = None,
|
||||
@@ -5103,8 +5105,17 @@ class BrowserDispatcher(Dispatcher):
|
||||
def events_gate(self):
|
||||
"""Hold the delivery of the events of every session: the engine's reader waits (at most `GATE_WAIT_S`) at its next event of a
|
||||
session. For a short step that waits for no event and no reply: a page subscribes its readers and is handed the events it missed."""
|
||||
with self._events_gate:
|
||||
got = self._events_gate.acquire(timeout=self.PAGE_GATE_WAIT_S)
|
||||
if not got:
|
||||
# the reader is stuck inside a handler: the page is built all the same (the old, unordered way), and it is said
|
||||
warnings.warn("invisible_playwright: the engine's events were held for more than %.0f s by a handler; a page is built without "
|
||||
"the gate of the events (its replay may be overtaken by a live event)" % self.PAGE_GATE_WAIT_S,
|
||||
RuntimeWarning, stacklevel=3)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if got:
|
||||
self._events_gate.release()
|
||||
|
||||
def replay(self, session: str, deliver) -> int:
|
||||
"""Hand a new consumer the events of its session that it missed.
|
||||
|
||||
@@ -163,3 +163,28 @@ def test_a_gate_that_is_never_let_go_costs_the_reader_one_wait_and_is_said():
|
||||
finally:
|
||||
release.set()
|
||||
world.close()
|
||||
|
||||
|
||||
def test_a_page_built_while_the_reader_is_stuck_in_a_handler_is_built_all_the_same_and_it_is_said():
|
||||
import warnings
|
||||
|
||||
world = World()
|
||||
held, release = threading.Event(), threading.Event()
|
||||
try:
|
||||
world.browser.PAGE_GATE_WAIT_S = 0.2
|
||||
|
||||
def stuck_reader():
|
||||
with world.browser.events_gate():
|
||||
held.set()
|
||||
release.wait(10)
|
||||
t = threading.Thread(target=stuck_reader, daemon=True)
|
||||
t.start()
|
||||
assert held.wait(5)
|
||||
with warnings.catch_warnings(record=True) as caught:
|
||||
warnings.simplefilter("always")
|
||||
with world.browser.events_gate():
|
||||
pass
|
||||
assert any("held for more than" in str(w.message) for w in caught), [str(w.message) for w in caught]
|
||||
finally:
|
||||
release.set()
|
||||
world.close()
|
||||
Reference in new issue
Block a user