Close the handler in _uninstall_scrapy_root_handler().

This commit is contained in:
Andrey Rakhmatullin 2026-06-20 00:22:20 +05:00
parent 994b4e7fc5
commit a171749f95
1 changed files with 5 additions and 4 deletions

View File

@ -149,11 +149,12 @@ def install_scrapy_root_handler(settings: Settings) -> None:
def _uninstall_scrapy_root_handler() -> None:
global _scrapy_root_handler # noqa: PLW0603
if (
_scrapy_root_handler is not None
and _scrapy_root_handler in logging.root.handlers
):
if _scrapy_root_handler is None:
return
if _scrapy_root_handler in logging.root.handlers:
logging.root.removeHandler(_scrapy_root_handler)
_scrapy_root_handler.close()
_scrapy_root_handler = None