File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,6 @@ async def run_custom_agent(
199
199
controller = CustomController ()
200
200
playwright = None
201
201
browser_context_ = None
202
- browser = None # Initialize browser to None
203
202
try :
204
203
if use_own_browser :
205
204
playwright = await async_playwright ().start ()
@@ -279,17 +278,15 @@ async def run_custom_agent(
279
278
model_actions = ""
280
279
model_thoughts = ""
281
280
finally :
282
- # Close persistent context if it was initialized
281
+ # 显式关闭持久化上下文
283
282
if browser_context_ :
284
283
await browser_context_ .close ()
285
284
286
- # Stop Playwright if it was started
285
+ # 关闭 Playwright 对象
287
286
if playwright :
288
287
await playwright .stop ()
288
+ await browser .close ()
289
289
290
- # Close the browser if it was initialized
291
- if browser :
292
- await browser .close ()
293
290
294
291
return final_result , errors , model_actions , model_thoughts
295
292
You can’t perform that action at this time.
0 commit comments