Skip to content

Commit 0597b73

Browse files
committed
Address feedback.
1 parent 265ce8e commit 0597b73

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

sdks/python/apache_beam/runners/worker/data_plane.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ def _clean_receiving_queue(self, instruction_id):
502502
instruction_id cannot be reused for new queue.
503503
"""
504504
with self._receive_lock:
505+
# Per-instruction read queue may or may not be created yet when
506+
# we mark an instruction as 'cleaned up' when creating
507+
# a bundle processor failed, e.g. due to a flake in DoFn.setup().
508+
# We want to mark an instruction as cleaned up regardless.
505509
self._received.pop(instruction_id, None)
506510
self._cleaned_instruction_ids[instruction_id] = True
507511
while len(self._cleaned_instruction_ids) > _MAX_CLEANED_INSTRUCTIONS:
@@ -857,13 +861,13 @@ def create_data_channel(self, remote_grpc_port):
857861
def close(self):
858862
# type: () -> None
859863
_LOGGER.info('Closing all cached grpc data channels.')
860-
for _, channel in self._data_channel_cache.items():
864+
for channel in list(self._data_channel_cache.values()):
861865
channel.close()
862866
self._data_channel_cache.clear()
863867

864868
def cleanup(self, instruction_id):
865869
# type: (str) -> None
866-
for channel in self._data_channel_cache.values():
870+
for channel in list(self._data_channel_cache.values()):
867871
channel._clean_receiving_queue(instruction_id)
868872

869873

0 commit comments

Comments
 (0)