|
|
|
@ -22,7 +22,6 @@ import six |
|
|
|
|
import grpc |
|
|
|
|
from tests.unit.framework.common import test_constants |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_WAIT_FOR_BLOCKING = datetime.timedelta(seconds=1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -31,13 +30,18 @@ def _block_on_waiting(server, termination_event): |
|
|
|
|
server.wait_for_termination() |
|
|
|
|
termination_event.set() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServerWaitForTerminationTest(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
def test_unblock_by_invoking_stop(self): |
|
|
|
|
termination_event = threading.Event() |
|
|
|
|
server = grpc.server(futures.ThreadPoolExecutor()) |
|
|
|
|
|
|
|
|
|
wait_thread = threading.Thread(target=_block_on_waiting, args=(server, termination_event,)) |
|
|
|
|
wait_thread = threading.Thread( |
|
|
|
|
target=_block_on_waiting, args=( |
|
|
|
|
server, |
|
|
|
|
termination_event, |
|
|
|
|
)) |
|
|
|
|
wait_thread.daemon = True |
|
|
|
|
wait_thread.start() |
|
|
|
|
time.sleep(_WAIT_FOR_BLOCKING.total_seconds()) |
|
|
|
@ -50,7 +54,11 @@ class ServerWaitForTerminationTest(unittest.TestCase): |
|
|
|
|
termination_event = threading.Event() |
|
|
|
|
server = grpc.server(futures.ThreadPoolExecutor()) |
|
|
|
|
|
|
|
|
|
wait_thread = threading.Thread(target=_block_on_waiting, args=(server, termination_event,)) |
|
|
|
|
wait_thread = threading.Thread( |
|
|
|
|
target=_block_on_waiting, args=( |
|
|
|
|
server, |
|
|
|
|
termination_event, |
|
|
|
|
)) |
|
|
|
|
wait_thread.daemon = True |
|
|
|
|
wait_thread.start() |
|
|
|
|
time.sleep(_WAIT_FOR_BLOCKING.total_seconds()) |