Get cancellation grace period correctly

This changes the logic of getting cancellation grace
period of task runner before closing it: to move the
liveness check into the cancel_all() method in the
scheduler rather than ask the resource if it's IN_PROGRESS.

Change-Id: Ia2a03de227ff15cdce1b3dbb6cd6bff6c5a50a15
Partial-Bug: 1693495
(cherry picked from commit 8c62e96947)
This commit is contained in:
huangtianhua 2017-06-24 18:44:59 +08:00
parent 8cdf5473ac
commit 5034bc10af
2 changed files with 4 additions and 4 deletions

View File

@ -1062,9 +1062,6 @@ class Resource(object):
)
def cancel_grace_period(self):
if self.status != self.IN_PROGRESS:
return None
canceller = getattr(self,
'handle_%s_cancel' % self.action.lower(),
None)

View File

@ -473,7 +473,10 @@ class DependencyTaskGroup(object):
return grace_period
for k, r in six.iteritems(self._runners):
gp = get_grace_period(k)
if not r.started() or r.done():
gp = None
else:
gp = get_grace_period(k)
try:
r.cancel(grace_period=gp)
except Exception as ex: