Skip to content

Commit

Permalink
fix: signal terminate in BidiReadObject (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
cojenco authored Nov 21, 2024
1 parent 6027b39 commit d6fe248
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions testbench/grpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from collections.abc import Iterable
from concurrent import futures
from queue import Queue
from threading import Thread
from threading import Thread, Timer

import crc32c
import google.protobuf.any_pb2 as any_pb2
Expand Down Expand Up @@ -609,6 +609,12 @@ def gather_requests(initial_ranges):
target=gather_requests, args=(first_message.read_ranges,)
)

def terminate_w_timer():
nonlocal responses
responses.put(("terminate", None))

timer_thread = Timer(10, terminate_w_timer)

poll_queue = True

# Check retry test broken-stream instructions.
Expand All @@ -628,6 +634,7 @@ def gather_requests(initial_ranges):
)
try:
gather_thread.start()
timer_thread.start()

while poll_queue:
action, arg = responses.get()
Expand Down Expand Up @@ -673,7 +680,7 @@ def gather_requests(initial_ranges):
action, _ = responses.get()
if action == "terminate":
poll_queue = False
gather_thread.join()
gather_thread.join(timeout=10)

def _to_read_range_error_proto(self, range, status_code):
return storage_pb2.ReadRangeError(
Expand Down

0 comments on commit d6fe248

Please sign in to comment.