Skip to content

Commit fd07ecb

Browse files
linesightclaude
andcommitted
unittests: fix main_test shutdown on macOS
The main_test hardening added a pre-Shutdown wait for GetBrowserByIdentifier(MAIN_BROWSER_ID) to return None. All five macOS jobs timed out there even though the JavaScript, popup, DevTools and handler callbacks had completed. CloseBrowser(True) starts an asynchronous native close and does not guarantee that a synchronously created macOS browser reaches OnBeforeClose before Shutdown. This matches upstream CEF issues chromiumembedded/cef#3469 and chromiumembedded/cef#3810. cefpython removes the browser from its registry in OnBeforeClose, so registry disappearance is not a portable pre-Shutdown condition. Remove only that close wait and restore the existing 25-iteration MessageLoopWork grace period. Keep the condition-driven pre-close completion gate that fixes the original Windows Python 3.14 timing failure, and let cef.Shutdown() perform its existing final browser cleanup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 887dc7a commit fd07ecb

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

unittests/main_test.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,10 @@ def shutdown_cef():
327327
del browser
328328
subtest_message("browser.CloseBrowser() ok")
329329

330-
# Browser destruction is asynchronous. Wait for the registry entry to
331-
# disappear before checking callback assertions and shutting CEF down.
332-
browser_closed = run_message_loop_until(
333-
lambda: cef.GetBrowserByIdentifier(MAIN_BROWSER_ID) is None)
334-
self.assertTrue(browser_closed,
335-
"Timed out waiting for the main browser to close")
336-
# OnBeforeClose removes the Python registry entry before all native CEF
337-
# teardown work has settled. Process a short grace period before
338-
# Shutdown() to avoid racing those remaining tasks.
330+
# CloseBrowser() is asynchronous. Process pending close work before
331+
# checking callbacks and shutting CEF down. For synchronously created
332+
# macOS browsers, OnBeforeClose may be deferred until Shutdown()
333+
# (CEF issues #3469 and #3810).
339334
do_message_loop_work(25)
340335

341336
# Asserts before shutdown

0 commit comments

Comments
 (0)