From dbd8b1bff9afd8f05f982bcd52c20bc173c266ca Mon Sep 17 00:00:00 2001 From: Simon Sawicki Date: Sun, 10 Mar 2024 16:14:53 +0100 Subject: [PATCH] Improve 069b2aedae2279668b6051627a81fc4fbd9c146a Authored by: Grub4k --- yt_dlp/YoutubeDL.py | 5 +++-- yt_dlp/networking/common.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 2a0fabfd7..08d608a52 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -962,8 +962,9 @@ def __exit__(self, *args): def close(self): self.save_cookies() - self._request_director.close() - del self._request_director + if '_request_director' in self.__dict__: + self._request_director.close() + del self._request_director def trouble(self, message=None, tb=None, is_error=True): """Determine action to take when a download problem appears. diff --git a/yt_dlp/networking/common.py b/yt_dlp/networking/common.py index 7da2652ae..e43d74ead 100644 --- a/yt_dlp/networking/common.py +++ b/yt_dlp/networking/common.py @@ -68,7 +68,7 @@ def __init__(self, logger, verbose=False): def close(self): for handler in self.handlers.values(): handler.close() - self.handlers = {} + self.handlers.clear() def add_handler(self, handler: RequestHandler): """Add a handler. If a handler of the same RH_KEY exists, it will overwrite it"""