Skip to content

Commit

Permalink
fix tqdm lock deletion (#6068)
Browse files Browse the repository at this point in the history
* fix tqdm lock deletion

* comment

* style
  • Loading branch information
lhoestq authored Jul 25, 2023
1 parent 971e33e commit 6063ea2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/datasets/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down

0 comments on commit 6063ea2

Please sign in to comment.