Github user GEOFBOT commented on a diff in the pull request:
https://github.com/apache/flink/pull/3232#discussion_r98599687
--- Diff:
flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/PythonPlanBinder.java
---
@@ -139,15 +139,28 @@ private void runPlan(String[] args) throws Exception {
String tmpPath = FLINK_PYTHON_FILE_PATH + r.nextInt();
prepareFiles(tmpPath, Arrays.copyOfRange(args, 0, split
== 0 ? args.length : split));
startPython(tmpPath, Arrays.copyOfRange(args, split ==
0 ? args.length : split + 1, args.length));
- receivePlan();
- if (env instanceof LocalEnvironment) {
- FLINK_HDFS_PATH = "file:" +
System.getProperty("java.io.tmpdir") + File.separator + "flink";
+ // Python process should terminate itself when all jobs
have been run
+ while (streamer.isPythonRunning()) {
+ try {
+ receivePlan();
+ } catch (SocketTimeoutException ste) {
+ // If the socket times out, check to
see if Python process has exited yet
+ continue;
+ }
+
+ if (env instanceof LocalEnvironment) {
+ FLINK_HDFS_PATH = "file:" +
System.getProperty("java.io.tmpdir") + File.separator + "flink";
+ }
+
+ distributeFiles(tmpPath, env);
+ JobExecutionResult jer = env.execute();
+ sendResult(jer);
+
+ environmentCounter++;
}
- distributeFiles(tmpPath, env);
- JobExecutionResult jer = env.execute();
- sendResult(jer);
+ clearPath(tmpPath);
--- End diff --
The files necessary for plan mode (Flink python module, plan file, etc.)
are copied with `prepareFiles` on L140. If `clearPath` is left at L203 inside
of `distributeFiles`, those necessary Python files will be removed after the
first job is executed and subsequent jobs can't be run.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---