Fixed handle leak

This commit is contained in:
2025-08-09 16:13:25 +02:00
parent a0e38071d8
commit abdcef0a80

View File

@ -16,7 +16,7 @@ class CaptchaException(Exception):
def __init__(self, *argv: any):
# Reset scraper
global scraper
scraper = Scraper()
scraper.reset()
# Construct the exception
super().__init__(self, *argv)
@ -44,7 +44,11 @@ class Scraper:
def _retry_get(self, url: str, body: bool) -> bytes | Response:
return self._get(url, body=body)
def close(self):
self._scraper.close()
def reset(self):
self._scraper.close()
self._scraper = CloudScraper()
def get(self, url: str, retry: bool = True, body: bool = True):