From 6063ea2069c8b5641b983ba2c1d39b60afe7c00a Mon Sep 17 00:00:00 2001 From: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com> Date: Tue, 25 Jul 2023 17:17:49 +0200 Subject: [PATCH] fix tqdm lock deletion (#6068) * fix tqdm lock deletion * comment * style --- src/datasets/utils/logging.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/datasets/utils/logging.py b/src/datasets/utils/logging.py index a2c3becd741..c379820143f 100644 --- a/src/datasets/utils/logging.py +++ b/src/datasets/utils/logging.py @@ -202,8 +202,6 @@ def __exit__(self, type_, value, traceback): class _tqdm_cls: - _lock = None - def __call__(self, *args, disable=False, **kwargs): if _tqdm_active and not disable: return tqdm_lib.tqdm(*args, **kwargs) @@ -219,6 +217,14 @@ def get_lock(self): if _tqdm_active: return tqdm_lib.tqdm.get_lock() + def __delattr__(self, attr): + """fix for https://github.com/huggingface/datasets/issues/6066""" + try: + del self.__dict__[attr] + except KeyError: + if attr != "_lock": + raise AttributeError(attr) + tqdm = _tqdm_cls()