|
|
|
@ -337,10 +337,13 @@ class _Kernel(object): |
|
|
|
|
self._server.start() |
|
|
|
|
self._server.service(None) |
|
|
|
|
|
|
|
|
|
def graceful_stop(self): |
|
|
|
|
def begin_stop(self): |
|
|
|
|
with self._lock: |
|
|
|
|
self._server.stop() |
|
|
|
|
self._server = None |
|
|
|
|
|
|
|
|
|
def end_stop(self): |
|
|
|
|
with self._lock: |
|
|
|
|
self._completion_queue.stop() |
|
|
|
|
self._completion_queue = None |
|
|
|
|
pool = self._pool |
|
|
|
@ -348,11 +351,6 @@ class _Kernel(object): |
|
|
|
|
self._rpc_states = None |
|
|
|
|
pool.shutdown(wait=True) |
|
|
|
|
|
|
|
|
|
def immediate_stop(self): |
|
|
|
|
# TODO(nathaniel): Implementation. |
|
|
|
|
raise NotImplementedError( |
|
|
|
|
'TODO(nathaniel): after merge of rewritten lower layers') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServiceLink(links.Link): |
|
|
|
|
"""A links.Link for use on the service-side of a gRPC connection. |
|
|
|
@ -386,18 +384,20 @@ class ServiceLink(links.Link): |
|
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
|
def stop_gracefully(self): |
|
|
|
|
"""Stops this link. |
|
|
|
|
def begin_stop(self): |
|
|
|
|
"""Indicate imminent link stop and immediate rejection of new RPCs. |
|
|
|
|
|
|
|
|
|
New RPCs will be rejected as soon as this method is called, but ongoing RPCs |
|
|
|
|
will be allowed to continue until they terminate. This method blocks until |
|
|
|
|
all RPCs have terminated. |
|
|
|
|
will be allowed to continue until they terminate. This method does not |
|
|
|
|
block. |
|
|
|
|
""" |
|
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
|
def stop_immediately(self): |
|
|
|
|
"""Stops this link. |
|
|
|
|
def end_stop(self): |
|
|
|
|
"""Finishes stopping this link. |
|
|
|
|
|
|
|
|
|
begin_stop must have been called exactly once before calling this method. |
|
|
|
|
|
|
|
|
|
All in-progress RPCs will be terminated immediately. |
|
|
|
|
""" |
|
|
|
@ -424,12 +424,11 @@ class _ServiceLink(ServiceLink): |
|
|
|
|
self._relay.start() |
|
|
|
|
return self._kernel.start() |
|
|
|
|
|
|
|
|
|
def stop_gracefully(self): |
|
|
|
|
self._kernel.graceful_stop() |
|
|
|
|
self._relay.stop() |
|
|
|
|
def begin_stop(self): |
|
|
|
|
self._kernel.begin_stop() |
|
|
|
|
|
|
|
|
|
def stop_immediately(self): |
|
|
|
|
self._kernel.immediate_stop() |
|
|
|
|
def end_stop(self): |
|
|
|
|
self._kernel.end_stop() |
|
|
|
|
self._relay.stop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|