derrickaw commented on code in PR #37560:
URL: https://github.com/apache/beam/pull/37560#discussion_r2793164978
##########
sdks/python/apache_beam/yaml/yaml_mapping.py:
##########
@@ -205,85 +189,162 @@ def py_value_to_js_dict(py_value):
return py_value
-# TODO(yaml) Consider adding optional language version parameter to support
-# ECMAScript 5 and 6
+class PythonMonkeyDispatcher:
+ def __init__(self):
+ self._req_queue = queue.Queue()
+ self._resp_events = {}
+ self._resp_data = {}
+ self._lock = threading.Lock()
+ self._thread = threading.Thread(target=self._worker, daemon=True)
+ self._started = False
+
+ def start(self):
+ with self._lock:
+ if not self._started:
+ self._thread.start()
+ self._started = True
+ atexit.register(self.stop)
+
+ def stop(self):
+ # This method is called on process exit.
+ # We force an immediate exit to avoid a segmentation fault that often occur
+ # with pythonmonkey during standard Python interpreter finalization.
+ os._exit(0)
Review Comment:
Its necessary, but improved on the logic to flush out outputs to minimize
data loss.
--
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]