Simplify Browser setup concurrency

Keep dependency reconciliation, cache migration, and Chromium installation under the Browser hook's single setup lock. Remove the redundant nested installer lock from the Playwright helper.

Alessandro committed Aug 16, 2026 at 17:05 UTC 340d5ef9ddd273776cf9b6f0481a0b8d1c91f8cd
1 file changed +15 -18
plugins/_browser/helpers/playwright.py
+15 -18
@@ -3,7 +3,6 @@ import os
3 import re
4 import subprocess
5 import sys
6 -import threading
6 from importlib import resources
7 from pathlib import Path
8
@@ -19,7 +18,6 @@ RETIRED_PLAYWRIGHT_CACHE_DIRS = (
18 ("usr", "plugins", "_browser", "playwright"),
19 ("usr", "browser", "playwright"),
20 )
22 -_INSTALL_LOCK = threading.Lock()
21
22
23 def _primary_cache_dir() -> Path:
@@ -98,20 +96,19 @@ def get_playwright_chromium_revision() -> str:
96
97
98 def ensure_playwright_binary() -> Path:
101 - with _INSTALL_LOCK:
102 - binary = get_playwright_binary()
103 - if binary:
104 - return binary
105 -
106 - cache_dir = configure_playwright_env()
107 - env = os.environ.copy()
108 - env["PLAYWRIGHT_BROWSERS_PATH"] = cache_dir
109 - subprocess.check_call(
110 - [sys.executable, "-m", "patchright", "install", "chromium", "--no-shell"],
111 - env=env,
112 - )
113 -
114 - binary = get_playwright_binary()
115 - if not binary:
116 - raise RuntimeError("Patchright Chromium binary not found after installation")
99 + binary = get_playwright_binary()
100 + if binary:
101 return binary
102 +
103 + cache_dir = configure_playwright_env()
104 + env = os.environ.copy()
105 + env["PLAYWRIGHT_BROWSERS_PATH"] = cache_dir
106 + subprocess.check_call(
107 + [sys.executable, "-m", "patchright", "install", "chromium", "--no-shell"],
108 + env=env,
109 + )
110 +
111 + binary = get_playwright_binary()
112 + if not binary:
113 + raise RuntimeError("Patchright Chromium binary not found after installation")
114 + return binary