lukecwik commented on a change in pull request #11203: [BEAM-9577] Define and 
implement dependency-aware artifact staging service.
URL: https://github.com/apache/beam/pull/11203#discussion_r400604546
 
 

 ##########
 File path: sdks/python/apache_beam/runners/portability/artifact_service.py
 ##########
 @@ -284,12 +284,38 @@ def _open(self, path, mode='r'):
 # The dependency-aware artifact staging and retrieval services.
 
 
-def _queue_iter(queue, end_token):
-  while True:
-    item = queue.get()
-    if item is end_token:
-      break
-    yield item
+class _QueueIter(object):
+
+  _END = object()
+
+  def __init__(self):
+    self._queue = queue.Queue()
+
+  def put(self, item):
+    self._queue.put(item)
+
+  def done(self):
+    self._queue.put(self._END)
+    self._queue.put(StopIteration)
+
+  def abort(self, exn=None):
+    if exn is None:
+      exn = sys.exc_info()[1]
+    self._queue.put(self._END)
+    self._queue.put(exn)
+
+  def __iter__(self):
+    return self
+
+  def __next__(self):
+    item = self._queue.get()
 
 Review comment:
   so clever

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to