From f1f4d60e0a7721358d8dea8e3d5520ddee87afcf Mon Sep 17 00:00:00 2001 From: Sirushti Murugesan Date: Mon, 29 Jun 2015 09:05:43 +0530 Subject: [PATCH] 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 --- heat/engine/dependencies.py | 4 ++++ heat/engine/scheduler.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/heat/engine/dependencies.py b/heat/engine/dependencies.py index d488b5a390..f7fb7cafe9 100644 --- a/heat/engine/dependencies.py +++ b/heat/engine/dependencies.py @@ -71,6 +71,10 @@ class Node(object): '''Return True if this node is not a leaf (it requires other nodes).''' 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): '''Return True if this node is a stem (required by nothing).''' return not bool(self.satisfy) diff --git a/heat/engine/scheduler.py b/heat/engine/scheduler.py index ed79448d97..f9bb0f657b 100644 --- a/heat/engine/scheduler.py +++ b/heat/engine/scheduler.py @@ -283,6 +283,10 @@ class TaskRunner(object): """Return True if there are steps remaining.""" return not self.done() + def __bool__(self): + """Return True if there are steps remaining.""" + return self.__nonzero__() + def wrappertask(task): """