fix: logging file handler not closed on bot shutdown. Fixes #405

This commit is contained in:
sebthom
2025-02-09 04:23:24 +01:00
parent b4658407a3
commit 7169975d2a
2 changed files with 20 additions and 2 deletions

View File

@@ -60,6 +60,7 @@ class KleinanzeigenBot(WebScrapingMixin):
def __del__(self) -> None:
if self.file_log:
LOG_ROOT.removeHandler(self.file_log)
self.file_log.close()
self.close_browser_session()
def get_version(self) -> str:
@@ -707,7 +708,7 @@ class KleinanzeigenBot(WebScrapingMixin):
await self.web_sleep(1) # Wait for city dropdown to populate
options = await self.web_find_all(By.CSS_SELECTOR, "#pstad-citychsr option")
for option in options:
option_text = await self.web_text(By.CSS_SELECTOR, "option", parent=option)
option_text = await self.web_text(By.CSS_SELECTOR, "option", parent = option)
if option_text == ad_cfg["contact"]["location"]:
await self.web_select(By.ID, "pstad-citychsr", option_text)
break