I have a interface which has a button that closes the playwright context and browser, but when i close it, a lot of exceptions (because the playwright browser and context were closed during some actions) are raised and i couldn't ignore them with try/except. This is a problem because the exceptions always shutdown the interface window. Here is a sample of code:
def close_playwright():
context.close()
browser.close()
playwright = sync_playwright().start()
browser = playwright.webkit.launch()
context = self.browser.new_context(java_script_enabled=False)
page = context.new_page()
page.goto("https://example.com")
# do something
# sometime close_playwright() is called and the exceptions are raised