Skip to content

Commit

Permalink
Fix race for tqdm._instances between __init__ and other methods
Browse files Browse the repository at this point in the history
  • Loading branch information
orivej authored and casperdcl committed Jun 18, 2019
1 parent 71acad5 commit 86dfc61
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tqdm/_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,16 +839,18 @@ def __init__(self, iterable=None, desc=None, total=None, leave=True,
if disable:
self.iterable = iterable
self.disable = disable
self.pos = self._get_free_pos(self)
self._instances.remove(self)
with self._lock:
self.pos = self._get_free_pos(self)
self._instances.remove(self)
self.n = initial
self.total = total
return

if kwargs:
self.disable = True
self.pos = self._get_free_pos(self)
self._instances.remove(self)
with self._lock:
self.pos = self._get_free_pos(self)
self._instances.remove(self)
from textwrap import dedent
raise (TqdmDeprecationWarning(dedent("""\
`nested` is deprecated and automated.
Expand Down

0 comments on commit 86dfc61

Please sign in to comment.