Skip to content

Commit 6063ea2

Browse files
authored
fix tqdm lock deletion (#6068)
* fix tqdm lock deletion * comment * style
1 parent 971e33e commit 6063ea2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/datasets/utils/logging.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ def __exit__(self, type_, value, traceback):
202202

203203

204204
class _tqdm_cls:
205-
_lock = None
206-
207205
def __call__(self, *args, disable=False, **kwargs):
208206
if _tqdm_active and not disable:
209207
return tqdm_lib.tqdm(*args, **kwargs)
@@ -219,6 +217,14 @@ def get_lock(self):
219217
if _tqdm_active:
220218
return tqdm_lib.tqdm.get_lock()
221219

220+
def __delattr__(self, attr):
221+
"""fix for https://github.com/huggingface/datasets/issues/6066"""
222+
try:
223+
del self.__dict__[attr]
224+
except KeyError:
225+
if attr != "_lock":
226+
raise AttributeError(attr)
227+
222228

223229
tqdm = _tqdm_cls()
224230

0 commit comments

Comments
 (0)