|
|
@ -337,10 +337,13 @@ class _Kernel(object): |
|
|
|
self._server.start() |
|
|
|
self._server.start() |
|
|
|
self._server.service(None) |
|
|
|
self._server.service(None) |
|
|
|
|
|
|
|
|
|
|
|
def graceful_stop(self): |
|
|
|
def begin_stop(self): |
|
|
|
with self._lock: |
|
|
|
with self._lock: |
|
|
|
self._server.stop() |
|
|
|
self._server.stop() |
|
|
|
self._server = None |
|
|
|
self._server = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def end_stop(self): |
|
|
|
|
|
|
|
with self._lock: |
|
|
|
self._completion_queue.stop() |
|
|
|
self._completion_queue.stop() |
|
|
|
self._completion_queue = None |
|
|
|
self._completion_queue = None |
|
|
|
pool = self._pool |
|
|
|
pool = self._pool |
|
|
@ -348,11 +351,6 @@ class _Kernel(object): |
|
|
|
self._rpc_states = None |
|
|
|
self._rpc_states = None |
|
|
|
pool.shutdown(wait=True) |
|
|
|
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): |
|
|
|
class ServiceLink(links.Link): |
|
|
|
"""A links.Link for use on the service-side of a gRPC connection. |
|
|
|
"""A links.Link for use on the service-side of a gRPC connection. |
|
|
@ -386,18 +384,20 @@ class ServiceLink(links.Link): |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def stop_gracefully(self): |
|
|
|
def begin_stop(self): |
|
|
|
"""Stops this link. |
|
|
|
"""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 |
|
|
|
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 |
|
|
|
will be allowed to continue until they terminate. This method does not |
|
|
|
all RPCs have terminated. |
|
|
|
block. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def stop_immediately(self): |
|
|
|
def end_stop(self): |
|
|
|
"""Stops this link. |
|
|
|
"""Finishes stopping this link. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
begin_stop must have been called exactly once before calling this method. |
|
|
|
|
|
|
|
|
|
|
|
All in-progress RPCs will be terminated immediately. |
|
|
|
All in-progress RPCs will be terminated immediately. |
|
|
|
""" |
|
|
|
""" |
|
|
@ -424,12 +424,11 @@ class _ServiceLink(ServiceLink): |
|
|
|
self._relay.start() |
|
|
|
self._relay.start() |
|
|
|
return self._kernel.start() |
|
|
|
return self._kernel.start() |
|
|
|
|
|
|
|
|
|
|
|
def stop_gracefully(self): |
|
|
|
def begin_stop(self): |
|
|
|
self._kernel.graceful_stop() |
|
|
|
self._kernel.begin_stop() |
|
|
|
self._relay.stop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stop_immediately(self): |
|
|
|
def end_stop(self): |
|
|
|
self._kernel.immediate_stop() |
|
|
|
self._kernel.end_stop() |
|
|
|
self._relay.stop() |
|
|
|
self._relay.stop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|