fix: single-reader CDP session; prime walk no longer fails silently
prime ran the in-page click walk as a task while drain() also read the websocket. `websockets` forbids concurrent recv(), so this was always broken -- it just failed differently by version: loudly on websockets 15.0.1, and silently on 16.0, where the JS still executed but its return value was lost. The `walk: None` in every prime summary was that failure being swallowed by a bare `except Exception`, and I read past it. CDPSession now runs exactly one reader coroutine that dispatches command replies to futures and events to a queue, so call() and drain() can safely run concurrently -- which priming genuinely needs, since the requests being observed are triggered by the script being awaited. call() also gains a timeout so a lost reply fails instead of hanging, and the walk now reports its error rather than reporting None. Tests use a fake websocket that asserts the socket never has more than one concurrent reader. 129 tests, no network required. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
5a61890011
commit
06122c66dd
4 files changed
+226
-31
No files matched your search
+4
-1
@@ -13,7 +13,7 @@ dependencies = []
|
||||
# CDP is a WebSocket protocol, so priming needs a client. The query path is
|
||||
# deliberately stdlib-only.
|
||||
prime = ["websockets>=12"]
|
||||
dev = ["pytest>=8"]
|
||||
dev = ["pytest>=8", "pytest-asyncio>=0.23"]
|
||||
|
||||
[project.scripts]
|
||||
wodify = "wodify.cli:main"
|
||||
@@ -23,3 +23,6 @@ where = ["src"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
# The CDP session spawns its reader task on construction, so its fixtures must
|
||||
# be built inside a running loop.
|
||||
asyncio_mode = "auto"
|
||||
Reference in new issue
Block a user