From 4b41ba249df4f290b3551b82b6004a0ce77bf2cf Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Fri, 28 Aug 2015 15:48:23 +0000 Subject: [PATCH] Two fixes in grpc.framework.core._end (1) Call "cancel" on each future, not on the list of futures. (2) If and when futures mature their actions should simply abort all outstanding operations and cancel any other futures. They should not shut down the _End's internal thread pool; only the termination action of the last operation to terminate should shut down the pool (in the case of their having been active operations at the time at which the _End's stop(grace) method was called). --- src/python/grpcio/grpc/framework/core/_end.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/python/grpcio/grpc/framework/core/_end.py b/src/python/grpcio/grpc/framework/core/_end.py index fb2c532df61..5ef2f6d3a36 100644 --- a/src/python/grpcio/grpc/framework/core/_end.py +++ b/src/python/grpcio/grpc/framework/core/_end.py @@ -30,7 +30,6 @@ """Implementation of base.End.""" import abc -import enum import threading import uuid @@ -75,7 +74,7 @@ def _abort(operations): def _cancel_futures(futures): for future in futures: - futures.cancel() + future.cancel() def _future_shutdown(lock, cycle, event): @@ -83,8 +82,6 @@ def _future_shutdown(lock, cycle, event): with lock: _abort(cycle.operations.values()) _cancel_futures(cycle.futures) - pool = cycle.pool - cycle.pool.shutdown(wait=True) return in_future @@ -113,6 +110,7 @@ def _termination_action(lock, stats, operation_id, cycle): cycle.idle_actions = [] if cycle.grace: _cancel_futures(cycle.futures) + cycle.pool.shutdown(wait=False) return termination_action