solve missing "pos" AttributeError on initialisation

- fixes #323

(probably)
This commit is contained in:
Casper da Costa-Luis 2018-04-20 23:59:50 +01:00
parent 162a1ac66f
commit 7f1590e27e
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 6 additions and 5 deletions

View File

@ -424,7 +424,7 @@ class tqdm(object):
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
@ -842,10 +842,11 @@ class tqdm(object):
# 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