Skip to content

Commit

Permalink
feat(playwright): add closed flag
Browse files Browse the repository at this point in the history
  • Loading branch information
idiotWu committed Feb 4, 2025
1 parent 1faa38a commit faae7ac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions npiai/core/browser/_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def _prepare_browser_utils():
class PlaywrightContext:
headless: bool
ready: bool
closed: bool
playwright: Playwright | None
browser: Browser | None
context: BrowserContext | None
Expand All @@ -63,6 +64,7 @@ def __init__(
"""
self.headless = headless
self.ready = False
self.closed = False
self.playwright = None
self.browser = None
self.context = None
Expand All @@ -86,6 +88,7 @@ async def start(self):
await self.restore_state(self.storage_state)

self.ready = True
self.closed = False

async def get_state(self) -> StorageState:
return await self.context.storage_state()
Expand Down Expand Up @@ -207,3 +210,5 @@ async def stop(self):
await self.context.close()
await self.browser.close()
await self.playwright.stop()
self.ready = False
self.closed = True

0 comments on commit faae7ac

Please sign in to comment.