Add __bool__ for classes that implement __nonzero__
__nonzero__ has been renamed to __bool__ in python3.4. So add the __bool__ magic method that will in turn call the existing __nonzero__ method. This avoids the scheduler going into an infinte loop when it checks for the no. of tasks remaining. partial blueprint heat-python34-support Change-Id: I5de554805a2af9abc15808427ce489720287f6b3
This commit is contained in:
parent
46233d2c2a
commit
f1f4d60e0a
@ -71,6 +71,10 @@ class Node(object):
|
|||||||
'''Return True if this node is not a leaf (it requires other nodes).'''
|
'''Return True if this node is not a leaf (it requires other nodes).'''
|
||||||
return bool(self.require)
|
return bool(self.require)
|
||||||
|
|
||||||
|
def __bool__(self):
|
||||||
|
'''Return True if this node is not a leaf (it requires other nodes).'''
|
||||||
|
return self.__nonzero__()
|
||||||
|
|
||||||
def stem(self):
|
def stem(self):
|
||||||
'''Return True if this node is a stem (required by nothing).'''
|
'''Return True if this node is a stem (required by nothing).'''
|
||||||
return not bool(self.satisfy)
|
return not bool(self.satisfy)
|
||||||
|
@ -283,6 +283,10 @@ class TaskRunner(object):
|
|||||||
"""Return True if there are steps remaining."""
|
"""Return True if there are steps remaining."""
|
||||||
return not self.done()
|
return not self.done()
|
||||||
|
|
||||||
|
def __bool__(self):
|
||||||
|
"""Return True if there are steps remaining."""
|
||||||
|
return self.__nonzero__()
|
||||||
|
|
||||||
|
|
||||||
def wrappertask(task):
|
def wrappertask(task):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user