This commit is contained in:
@@ -11,6 +11,8 @@ async def safe_browser_operation(url, operation_func):
|
|||||||
browser = None
|
browser = None
|
||||||
context = None
|
context = None
|
||||||
page = None
|
page = None
|
||||||
|
playwright = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Get or create playwright instance
|
# Get or create playwright instance
|
||||||
playwright = await async_playwright().start()
|
playwright = await async_playwright().start()
|
||||||
@@ -64,4 +66,10 @@ async def safe_browser_operation(url, operation_func):
|
|||||||
await browser.close()
|
await browser.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error closing browser: {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