Enhance Windows Compatibility with Event Loop Policy and Path Resolution (#3986)
Co-authored-by: Suchintan <suchintan@users.noreply.github.com> Co-authored-by: Shuchang Zheng <wintonzheng0325@gmail.com> Co-authored-by: Stanislav Novosad <stas@skyvern.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import platform
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
@@ -8,6 +9,28 @@ from alembic.config import Config
|
||||
from skyvern.constants import REPO_ROOT_DIR
|
||||
|
||||
|
||||
def setup_windows_event_loop_policy() -> None:
|
||||
"""
|
||||
Ensure the Windows event loop policy supports subprocesses (required by Playwright).
|
||||
|
||||
Explicitly setting the Proactor event loop policy prevents third-party packages or older
|
||||
Python defaults from forcing the Selector policy, which does not implement subprocess
|
||||
transports and causes runtime failures when Playwright tries to launch a browser.
|
||||
"""
|
||||
if platform.system() != "Windows":
|
||||
return
|
||||
|
||||
windows_policy_cls = getattr(asyncio, "WindowsProactorEventLoopPolicy", None)
|
||||
if windows_policy_cls is None:
|
||||
return
|
||||
|
||||
current_policy = asyncio.get_event_loop_policy()
|
||||
if isinstance(current_policy, windows_policy_cls):
|
||||
return
|
||||
|
||||
asyncio.set_event_loop_policy(windows_policy_cls())
|
||||
|
||||
|
||||
def migrate_db() -> None:
|
||||
alembic_cfg = Config()
|
||||
path = f"{REPO_ROOT_DIR}/alembic"
|
||||
|
||||
Reference in New Issue
Block a user