Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

wrap windows async adjustment in except

Nick Sweeting2195ce6e1b51
diff --git a/browser_use/__init__.py b/browser_use/__init__.py
index c7ec40c0c..30a37bdac 100644
--- a/browser_use/__init__.py
+++ b/browser_use/__init__.py
@@ -3,11 +3,14 @@ import sys
from browser_use.logging_config import setup_logging
-setup_logging()
+logger = setup_logging()
# Set Windows event loop policy for Playwright compatibility
if sys.platform.startswith('win'):
- asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
+ try:
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
+ except Exception as e:
+ logger.error(f'❌ Failed to set Windows event loop policy: {type(e).__name__}: {e}')
from browser_use.agent.prompts import SystemPrompt
from browser_use.agent.service import Agent
diff --git a/browser_use/logging_config.py b/browser_use/logging_config.py
index 4b62d6141..5138e8d28 100644
--- a/browser_use/logging_config.py
+++ b/browser_use/logging_config.py
@@ -137,3 +137,5 @@ def setup_logging():
third_party = logging.getLogger(logger_name)
third_party.setLevel(logging.ERROR)
third_party.propagate = False
+
+ return logger