stop playwright during browser teardown

This commit is contained in:
Nick Sweeting
2025-06-06 01:23:47 -07:00
parent 683a97e475
commit 9b3dd67dad
3 changed files with 7 additions and 11 deletions

View File

@@ -420,12 +420,12 @@ class BrowserSession(BaseModel):
)
# Close playwright if we own it
# if self.playwright:
# try:
# await self.playwright.stop()
# self.playwright = None
# except Exception as e:
# self.logger.debug(f'Error stopping playwright: {type(e).__name__}: {e}')
if self.playwright:
try:
await self.playwright.stop()
self.playwright = None
except Exception as e:
self.logger.debug(f'Error stopping playwright: {type(e).__name__}: {e}')
self._reset_connection_state()

View File

@@ -161,7 +161,3 @@ async def test_actual_download_detection(test_server, tmp_path):
assert duration < 2.0, f'Download detection took {duration:.2f}s, expected <2s'
await browser_session.close()
if __name__ == '__main__':
pytest.main([__file__, '-v', '-s'])

View File

@@ -453,4 +453,4 @@ class TestTabManagement:
assert browser_session.browser_context != original_context
assert browser_session.initialized is True
await browser_session.stop()
await browser_session.kill()