github-actions[bot] commented on code in PR #41531:
URL: https://github.com/apache/beam/pull/41531#discussion_r4668568345
##########
sdks/python/apache_beam/runners/portability/portable_runner.py:
##########
@@ -218,15 +217,18 @@ def run(
Iterator[beam_job_api_pb2.JobMessagesResponse]]:
"""Run the job"""
try:
+ # Use a timeout only for the check below to keep it from hanging.
state_stream = self.job_service.GetStateStream(
beam_job_api_pb2.GetJobStateRequest(job_id=preparation_id),
timeout=self.timeout)
# If there's an error, we don't always get it until we try to read.
# Fortunately, there's always an immediate current state published.
- state_stream = itertools.chain([next(state_stream)], state_stream)
+ next(state_stream)
Review Comment:
**🟢 Low**: After calling `next(state_stream)`, `state_stream` is reassigned
on line 228 without closing the initial stream. Because `GetStateStream` is a
server-streaming RPC that remains open until the job reaches a terminal state
or the RPC times out, the first stream will stay active on the job server
(e.g., holding a goroutine in Prism or a queue in
`LocalJobServicer._state_queues`) until `self.timeout` expires or the job
finishes. Consider calling `state_stream.cancel()` (or `if
hasattr(state_stream, 'cancel'): state_stream.cancel()` to handle non-gRPC test
doubles) after `next(state_stream)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]