This is an automated email from the ASF dual-hosted git repository.

riteshghorse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bd4a1e525b [Typescript] stop service when done (#29929)
8bd4a1e525b is described below

commit 8bd4a1e525ba5f3256124ae331acf0cc48ad65f9
Author: Cheskel Twersky <twerskyches...@gmail.com>
AuthorDate: Fri Jan 5 16:15:32 2024 +0200

    [Typescript] stop service when done (#29929)
---
 sdks/typescript/src/apache_beam/runners/dataflow.ts | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/sdks/typescript/src/apache_beam/runners/dataflow.ts 
b/sdks/typescript/src/apache_beam/runners/dataflow.ts
index e7da1f7ada5..0a88b17f695 100644
--- a/sdks/typescript/src/apache_beam/runners/dataflow.ts
+++ b/sdks/typescript/src/apache_beam/runners/dataflow.ts
@@ -36,13 +36,20 @@ export function dataflowRunner(runnerOptions: {
       augmentedOptions.experiments.push("use_runner_v2");
       augmentedOptions.experiments.push("use_portable_job_submission");
       augmentedOptions.experiments.push("use_sibling_sdk_workers");
-      return new PortableRunner(
+      const service = PythonService.forModule(
+        "apache_beam.runners.dataflow.dataflow_job_service",
+        ["--port", "{{PORT}}"]
+      );
+      const result = new PortableRunner(
         runnerOptions as any,
-        PythonService.forModule(
-          "apache_beam.runners.dataflow.dataflow_job_service",
-          ["--port", "{{PORT}}"]
-        )
+        service
       ).runPipeline(pipeline, augmentedOptions);
+      result.then((res) => {
+        res.waitUntilFinish().then((_state) => {
+          service.stop();
+        });
+      });
+      return result;
     }
   })();
 }

Reply via email to