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).
pull/3124/head
Nathaniel Manista 9 years ago
parent 400e0cdd32
commit 4b41ba249d
  1. 6
      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

Loading…
Cancel
Save