Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Refactor file appending logic in FileSystem class to improve performance and readability by using a dedicated function for file operations.
Magnus Müllerf75d3e0fac03
diff --git a/browser_use/filesystem/file_system.py b/browser_use/filesystem/file_system.pyindex 0286e1873..c8ab3a49b 100644--- a/browser_use/filesystem/file_system.py+++ b/browser_use/filesystem/file_system.py@@ -73,7 +73,11 @@ class FileSystem:# Create a new executor for this operationwith ThreadPoolExecutor() as executor:# Run file append in a thread to avoid blocking- await asyncio.get_event_loop().run_in_executor(executor, lambda p=path, c=content: p.write_text(c, append=True))+ def append_to_file(file_path, data):+ with file_path.open('a') as f:+ f.write(data)++ await asyncio.get_event_loop().run_in_executor(executor, append_to_file, path, content)return f'Data appended to {file_name} successfully.'except Exception:return f"Error: Could not append to file '{file_name}'."