Skip to content

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

shorter log lines around browsersession closing

Nick Sweetingfd555173e900
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index dab7df013..c6f128999 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -258,7 +258,7 @@ class BrowserSession(BaseModel):
try:
await self.browser_context.close()
logger.info(
- 'πŸ›‘ Stopped the BrowserSession.browser_context '
+ 'πŸ›‘ Shut down the BrowserSession '
f'(keep_alive=False user_data_dir={_log_pretty_path(self.browser_profile.user_data_dir) or "<None (incognito)>"})'
)
self.browser_context = None
@@ -269,7 +269,7 @@ class BrowserSession(BaseModel):
try:
await self.browser.close()
logger.info(
- 'πŸ›‘ Stopped the BrowserSession.browser '
+ 'πŸ›‘ Shut down the BrowserSession '
f'(keep_alive=False user_data_dir={_log_pretty_path(self.browser_profile.user_data_dir) or "<None (incognito)>"})'
)
self.browser = None
@@ -280,7 +280,9 @@ class BrowserSession(BaseModel):
if self.browser_pid:
try:
psutil.Process(pid=self.browser_pid).terminate()
- logger.info(f'πŸ›‘ Stopped the BrowserSession.browser_pid={self.browser_pid} subprocess (keep_alive=False)')
+ logger.info(
+ f'πŸ›‘ Shut down the BrowserSession and subprocess with browser_pid={self.browser_pid} (keep_alive=False)'
+ )
self.browser_pid = None
except Exception as e:
if 'NoSuchProcess' not in type(e).__name__:
diff --git a/browser_use/utils.py b/browser_use/utils.py
index 865709b05..5004d176e 100644
--- a/browser_use/utils.py
+++ b/browser_use/utils.py
@@ -163,6 +163,10 @@ class SignalHandler:
print('\r', end='', flush=True, file=stderr)
print('\r', end='', flush=True)
+ # these ^^ attempts dont work as far as we can tell
+ # we still dont know what causes the broken input, if you know how to fix it, please let us know
+ print('(tip: press [Enter] once if your terminal behaves strangely after exiting)', file=stderr)
+
os._exit(0)
def sigint_handler(self) -> None: