This commit is contained in:
@@ -11,6 +11,8 @@ async def safe_browser_operation(url, operation_func):
|
||||
browser = None
|
||||
context = None
|
||||
page = None
|
||||
playwright = None
|
||||
|
||||
try:
|
||||
# Get or create playwright instance
|
||||
playwright = await async_playwright().start()
|
||||
@@ -64,4 +66,10 @@ async def safe_browser_operation(url, operation_func):
|
||||
await browser.close()
|
||||
except Exception as e:
|
||||
print(f"Error closing browser: {e}")
|
||||
# We don't re-raise here to avoid masking the original error
|
||||
|
||||
# Ensure playwright is closed properly - THIS IS THE KEY FIX
|
||||
if playwright:
|
||||
try:
|
||||
await playwright.stop()
|
||||
except Exception as e:
|
||||
print(f"Error closing playwright: {e}")
|
||||
Reference in New Issue
Block a user