Skip to content

Commit cfcc81e

Browse files
committed
Address feedback.
1 parent 0ad7d44 commit cfcc81e

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:
@@ -856,13 +860,13 @@ def create_data_channel(self, remote_grpc_port):
856860
def close(self):
857861
# type: () -> None
858862
_LOGGER.info('Closing all cached grpc data channels.')
859-
for _, channel in self._data_channel_cache.items():
863+
for channel in list(self._data_channel_cache.values()):
860864
channel.close()
861865
self._data_channel_cache.clear()
862866

863867
def cleanup(self, instruction_id):
864868
# type: (str) -> None
865-
for channel in self._data_channel_cache.values():
869+
for channel in list(self._data_channel_cache.values()):
866870
channel._clean_receiving_queue(instruction_id)
867871

868872

0 commit comments

Comments
 (0)