@@ -115,7 +115,18 @@ def get(self, url, **kwargs):
115115 driver = self .driver
116116 if hasattr (driver , "cdp_base" ):
117117 driver = driver .cdp_base
118- self .loop .run_until_complete (self .page .get (url , ** kwargs ))
118+ load_timeout = 60.0
119+ wait_timeout = 30.0
120+ if hasattr (sb_config , "_cdp_proxy" ) and sb_config ._cdp_proxy :
121+ load_timeout = 90.0
122+ wait_timeout = 45.0
123+ try :
124+ task = self .page .get (url , ** kwargs )
125+ self .loop .run_until_complete (
126+ asyncio .wait_for (task , timeout = load_timeout )
127+ )
128+ except asyncio .TimeoutError :
129+ print ("Timeout loading %s" % url )
119130 url_protocol = url .split (":" )[0 ]
120131 safe_url = True
121132 if url_protocol not in ["about" , "data" , "chrome" ]:
@@ -127,7 +138,14 @@ def get(self, url, **kwargs):
127138 else :
128139 time .sleep (0.012 )
129140 self .__slow_mode_pause_if_set ()
130- self .loop .run_until_complete (self .page .wait ())
141+ try :
142+ self .loop .run_until_complete (
143+ asyncio .wait_for (self .page .wait (), timeout = wait_timeout )
144+ )
145+ except asyncio .TimeoutError :
146+ pass
147+ except Exception :
148+ pass
131149
132150 def open (self , url , ** kwargs ):
133151 self .get (url , ** kwargs )
@@ -2909,4 +2927,15 @@ def __init__(self, url=None, **kwargs):
29092927 driver = cdp_util .start_sync (** kwargs )
29102928 loop = asyncio .new_event_loop ()
29112929 page = loop .run_until_complete (driver .get (url ))
2930+ wait_timeout = 30.0
2931+ if hasattr (sb_config , "_cdp_proxy" ) and sb_config ._cdp_proxy :
2932+ wait_timeout = 45.0
2933+ try :
2934+ loop .run_until_complete (
2935+ asyncio .wait_for (page .wait (), timeout = wait_timeout )
2936+ )
2937+ except asyncio .TimeoutError :
2938+ pass
2939+ except Exception :
2940+ pass
29122941 super ().__init__ (loop , page , driver )
0 commit comments