|
16 | 16 | import asyncio
|
17 | 17 | import argparse
|
18 | 18 | import os
|
19 |
| -import warnings |
20 |
| -import socket |
21 | 19 |
|
22 | 20 | logger = logging.getLogger(__name__)
|
23 | 21 |
|
|
53 | 51 | # Create the global agent state instance
|
54 | 52 | _global_agent_state = AgentState()
|
55 | 53 |
|
56 |
| -def suppress_connection_reset(func): |
57 |
| - async def wrapper(*args, **kwargs): |
58 |
| - try: |
59 |
| - return await func(*args, **kwargs) |
60 |
| - except ConnectionResetError: |
61 |
| - # Suppress the ConnectionResetError |
62 |
| - warnings.warn("Connection was reset. This is usually harmless.", RuntimeWarning) |
63 |
| - pass |
64 |
| - except socket.error as e: |
65 |
| - if e.winerror != 10054: # If it's not the specific connection reset error |
66 |
| - raise |
67 |
| - return wrapper |
68 |
| - |
69 | 54 | async def stop_agent():
|
70 | 55 | """Request the agent to stop and update UI with enhanced feedback"""
|
71 | 56 | global _global_agent_state, _global_browser_context, _global_browser
|
@@ -553,7 +538,6 @@ async def run_with_stream(
|
553 | 538 | "Base": Base()
|
554 | 539 | }
|
555 | 540 |
|
556 |
| -@suppress_connection_reset |
557 | 541 | async def close_global_browser():
|
558 | 542 | global _global_browser, _global_browser_context
|
559 | 543 |
|
@@ -869,9 +853,6 @@ def list_recordings(save_recording_path):
|
869 | 853 | return demo
|
870 | 854 |
|
871 | 855 | def main():
|
872 |
| - # Suppress asyncio connection reset warnings |
873 |
| - warnings.filterwarnings("ignore", message=".*forcibly closed.*") |
874 |
| - |
875 | 856 | parser = argparse.ArgumentParser(description="Gradio UI for Browser Agent")
|
876 | 857 | parser.add_argument("--ip", type=str, default="127.0.0.1", help="IP address to bind to")
|
877 | 858 | parser.add_argument("--port", type=int, default=7788, help="Port to listen on")
|
|
0 commit comments