[ 
https://issues.apache.org/jira/browse/BEAM-3645?focusedWorklogId=279654&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-279654
 ]

ASF GitHub Bot logged work on BEAM-3645:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Jul/19 11:12
            Start Date: 19/Jul/19 11:12
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on pull request #8979: [BEAM-3645] 
add multiplexing for python FnApiRunner
URL: https://github.com/apache/beam/pull/8979#discussion_r305294640
 
 

 ##########
 File path: sdks/python/apache_beam/runners/portability/fn_api_runner.py
 ##########
 @@ -92,34 +92,78 @@ class 
BeamFnControlServicer(beam_fn_api_pb2_grpc.BeamFnControlServicer):
   _DONE_MARKER = object()
 
   def __init__(self):
-    self._push_queue = queue.Queue()
     self._futures_by_id = dict()
-    self._read_thread = threading.Thread(
-        name='beam_control_read', target=self._read)
+    self._read_thread = None
     self._uid_counter = 0
     self._state = self.UNSTARTED_STATE
     self._lock = threading.Lock()
+    self._multi_worker_worker_handler = None
+    self._req_worker_mapping = {}
+    self._req_sent = collections.defaultdict(int)
+    self._req_received = collections.defaultdict(int)
+    self._logging_level = logging.getLevelName(
+        logging.getLogger().getEffectiveLevel())
 
   def Control(self, iterator, context):
     with self._lock:
       if self._state == self.DONE_STATE:
         return
       else:
         self._state = self.STARTED_STATE
-    self._inputs = iterator
+
+    metadata = dict((k, v) for k, v in context.invocation_metadata())
+    worker_id = metadata.get('worker_id')
+    if not worker_id:
+      raise RuntimeError('All workers communicate through gRPC should have '
+                         'worker_id. Received None.')
+
+    # wait until worker_handlers are added to MultiWorkerWorkerHandler
+    while not self._multi_worker_worker_handler:
+      time.sleep(0.5)
+      logging.info('Runner: Waiting for worker handlers are added to '
+                   'MultiWorkerWorkerHandler.')
+
+    worker_handler = self._multi_worker_worker_handler\
+      ._get_worker_handler(worker_id)
+    worker = worker_handler._worker_info
+    worker._set_input(iterator)
     # Note: We only support one client for now.
 
 Review comment:
   Is this still true?
 
----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 279654)
    Time Spent: 24h 10m  (was: 24h)

> Support multi-process execution on the FnApiRunner
> --------------------------------------------------
>
>                 Key: BEAM-3645
>                 URL: https://issues.apache.org/jira/browse/BEAM-3645
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core
>    Affects Versions: 2.2.0, 2.3.0
>            Reporter: Charles Chen
>            Assignee: Hannah Jiang
>            Priority: Major
>             Fix For: 2.15.0
>
>          Time Spent: 24h 10m
>  Remaining Estimate: 0h
>
> https://issues.apache.org/jira/browse/BEAM-3644 gave us a 15x performance 
> gain over the previous DirectRunner.  We can do even better in multi-core 
> environments by supporting multi-process execution in the FnApiRunner, to 
> scale past Python GIL limitations.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to