@@ -91,20 +91,6 @@ async def _get_context_creation_lock(self) -> Lock:
91
91
self ._context_creation_lock = Lock ()
92
92
return self ._context_creation_lock
93
93
94
- async def _get_browser_context (
95
- self ,
96
- browser_new_context_options : Mapping [str , Any ] | None = None ,
97
- proxy_info : ProxyInfo | None = None ,
98
- ) -> BrowserContext :
99
- """Ensure that the browser context is set."""
100
- async with await self ._get_context_creation_lock ():
101
- if not self ._browser_context :
102
- self ._browser_context = await self ._create_browser_context (
103
- browser_new_context_options = browser_new_context_options ,
104
- proxy_info = proxy_info ,
105
- )
106
- return self ._browser_context
107
-
108
94
@property
109
95
@override
110
96
def pages (self ) -> list [Page ]:
@@ -176,8 +162,13 @@ async def new_page(
176
162
)
177
163
page = await new_context .new_page ()
178
164
else :
179
- _browser_context = await self ._get_browser_context ()
180
- page = await _browser_context .new_page ()
165
+ async with await self ._get_context_creation_lock ():
166
+ if not self ._browser_context :
167
+ self ._browser_context = await self ._create_browser_context (
168
+ browser_new_context_options = browser_new_context_options ,
169
+ proxy_info = proxy_info ,
170
+ )
171
+ page = await self ._browser_context .new_page ()
181
172
182
173
# Handle page close event
183
174
page .on (event = 'close' , f = self ._on_page_close )
0 commit comments