Skip to content

Commit

Permalink
solve missing "pos" AttributeError on initialisation
Browse files Browse the repository at this point in the history
- fixes #323

(probably)
  • Loading branch information
casperdcl committed Apr 20, 2018
1 parent b16a4f3 commit 2ede170
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tqdm/_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def __new__(cls, *args, **kwargs):
def _get_free_pos(cls, instance=None):
"""Skips specified instance"""
positions = set(abs(inst.pos) for inst in cls._instances
if inst is not instance)
if inst is not instance and hasattr(inst, "pos"))
return min(set(range(len(positions) + 1)).difference(positions))

@classmethod
Expand Down Expand Up @@ -842,10 +842,11 @@ def __init__(self, iterable=None, desc=None, total=None, leave=True,

# if nested, at initial sp() call we replace '\r' by '\n' to
# not overwrite the outer progress bar
if position is None:
self.pos = self._get_free_pos(self)
else: # mark fixed positions as negative
self.pos = -position
with self._lock:
if position is None:
self.pos = self._get_free_pos(self)
else: # mark fixed positions as negative
self.pos = -position

if not gui:
# Initialize the screen printer
Expand Down

0 comments on commit 2ede170

Please sign in to comment.