Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b849217

Browse files
committedJul 1, 2024··
Rename method, simplify variables
1 parent 65b7593 commit b849217

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed
 

‎scrapy_playwright/handler.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async def _maybe_launch_browser(self) -> None:
173173
self.browser = await self.browser_type.launch(**self.config.launch_options)
174174
logger.info("Browser %s launched", self.browser_type.name)
175175

176-
async def _maybe_connect_devtools(self) -> None:
176+
async def _maybe_connect_remote_devtools(self) -> None:
177177
async with self.browser_launch_lock:
178178
if not hasattr(self, "browser"):
179179
logger.info("Connecting using CDP: %s", self.config.cdp_url)
@@ -203,25 +203,21 @@ async def _create_browser_context(
203203
if hasattr(self, "context_semaphore"):
204204
await self.context_semaphore.acquire()
205205
context_kwargs = context_kwargs or {}
206+
persistent = remote = False
206207
if context_kwargs.get(PERSISTENT_CONTEXT_PATH_KEY):
207208
context = await self.browser_type.launch_persistent_context(**context_kwargs)
208209
persistent = True
209-
remote = False
210210
elif self.config.cdp_url:
211-
await self._maybe_connect_devtools()
211+
await self._maybe_connect_remote_devtools()
212212
context = await self.browser.new_context(**context_kwargs)
213-
persistent = False
214213
remote = True
215214
elif self.config.connect_url:
216215
await self._maybe_connect_remote()
217216
context = await self.browser.new_context(**context_kwargs)
218-
persistent = False
219217
remote = True
220218
else:
221219
await self._maybe_launch_browser()
222220
context = await self.browser.new_context(**context_kwargs)
223-
persistent = False
224-
remote = False
225221

226222
context.on(
227223
"close", self._make_close_browser_context_callback(name, persistent, remote, spider)

0 commit comments

Comments
 (0)
Please sign in to comment.