@@ -173,7 +173,7 @@ async def _maybe_launch_browser(self) -> None:
173
173
self .browser = await self .browser_type .launch (** self .config .launch_options )
174
174
logger .info ("Browser %s launched" , self .browser_type .name )
175
175
176
- async def _maybe_connect_devtools (self ) -> None :
176
+ async def _maybe_connect_remote_devtools (self ) -> None :
177
177
async with self .browser_launch_lock :
178
178
if not hasattr (self , "browser" ):
179
179
logger .info ("Connecting using CDP: %s" , self .config .cdp_url )
@@ -203,25 +203,21 @@ async def _create_browser_context(
203
203
if hasattr (self , "context_semaphore" ):
204
204
await self .context_semaphore .acquire ()
205
205
context_kwargs = context_kwargs or {}
206
+ persistent = remote = False
206
207
if context_kwargs .get (PERSISTENT_CONTEXT_PATH_KEY ):
207
208
context = await self .browser_type .launch_persistent_context (** context_kwargs )
208
209
persistent = True
209
- remote = False
210
210
elif self .config .cdp_url :
211
- await self ._maybe_connect_devtools ()
211
+ await self ._maybe_connect_remote_devtools ()
212
212
context = await self .browser .new_context (** context_kwargs )
213
- persistent = False
214
213
remote = True
215
214
elif self .config .connect_url :
216
215
await self ._maybe_connect_remote ()
217
216
context = await self .browser .new_context (** context_kwargs )
218
- persistent = False
219
217
remote = True
220
218
else :
221
219
await self ._maybe_launch_browser ()
222
220
context = await self .browser .new_context (** context_kwargs )
223
- persistent = False
224
- remote = False
225
221
226
222
context .on (
227
223
"close" , self ._make_close_browser_context_callback (name , persistent , remote , spider )
0 commit comments