Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions playwright/_impl/_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ async def connect(self) -> None:
self._stopped_future: asyncio.Future = asyncio.Future()

try:
# Get cwd asynchronously to avoid blocking the event loop.
# asyncio.create_subprocess_exec internally calls os.getcwd() when
# cwd is not specified, which blocks the event loop in ASGI servers.
cwd = await asyncio.to_thread(os.getcwd)

# For pyinstaller and Nuitka
env = get_driver_env()
if getattr(sys, "frozen", False) or globals().get("__compiled__"):
Expand All @@ -127,6 +132,7 @@ async def connect(self) -> None:
limit=32768,
env=env,
startupinfo=startupinfo,
cwd=cwd,
)
except Exception as exc:
self.on_error_future.set_exception(exc)
Expand Down