mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-04-11 06:02:07 -07:00
Fix cleanup on exception in sync_api __enter__
If an exception is raised in the synchronous api during the setup, super().__enter__ has been called but super().__exit__ will not get called, leading to asyncio runloop exceptions further down the line if one tries to create a new context. This commit catches the exception in order to clean up the super().__exit__ calls before reraising.
This commit is contained in:
parent
95cc4489d0
commit
e008580521
1 changed files with 5 additions and 1 deletions
|
|
@ -26,7 +26,11 @@ class Camoufox(PlaywrightContextManager):
|
|||
|
||||
def __enter__(self) -> Union[Browser, BrowserContext]:
|
||||
super().__enter__()
|
||||
self.browser = NewBrowser(self._playwright, **self.launch_options)
|
||||
try:
|
||||
self.browser = NewBrowser(self._playwright, **self.launch_options)
|
||||
except camoufox.exceptions.InvalidProxy as e:
|
||||
super().__exit__(camoufox.exceptions.InvalidProxy, e, None)
|
||||
raise
|
||||
return self.browser
|
||||
|
||||
def __exit__(self, *args: Any):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue