You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "exceptionfactory (via GitHub)" <gi...@apache.org> on 2026/02/01 03:27:24 UTC
Re: [PR] NIFI-15449 - NAR deletion blocks indefinitely when Python processor is initializing [nifi]
exceptionfactory commented on code in PR #10753:
URL: https://github.com/apache/nifi/pull/10753#discussion_r2750466232
##########
nifi-extension-bundles/nifi-py4j-extension-bundle/nifi-py4j-bridge/src/main/java/org/apache/nifi/py4j/StandardPythonProcessorBridge.java:
##########
@@ -46,6 +46,7 @@ public class StandardPythonProcessorBridge implements PythonProcessorBridge {
private volatile String identifier;
private volatile PythonController controller;
private volatile CompletableFuture<Void> initializationFuture;
+ private volatile boolean cancelled = false;
Review Comment:
Although either is technically acceptable English, other references in the project use `canceled` with one letter `L`, so I recommend using that form throughout these changes.
##########
nifi-extension-bundles/nifi-py4j-extension-bundle/nifi-py4j-bridge/src/main/java/org/apache/nifi/py4j/PythonProcess.java:
##########
@@ -346,17 +352,33 @@ private void setupEnvironment() throws IOException {
final String command = String.join(" ", processBuilder.command());
logger.debug("Creating Python Virtual Environment {} using command {}", virtualEnvHome, command);
- final Process process = processBuilder.start();
+ final Process venvProcess = processBuilder.start();
- final int result;
try {
- result = process.waitFor();
+ // Wait for the venv creation with periodic checks for shutdown
+ // This allows the venv creation to be interrupted when the process is being shut down
+ while (!venvProcess.waitFor(1, TimeUnit.SECONDS)) {
+ if (isShutdown()) {
+ logger.info("Interrupting Python Virtual Environment creation due to shutdown");
+ venvProcess.destroyForcibly();
+ throw new IOException("Python process shutdown during virtual environment creation");
Review Comment:
The Process ID would be helpful to include in this message.
##########
nifi-extension-bundles/nifi-py4j-extension-bundle/nifi-py4j-bridge/src/main/java/org/apache/nifi/py4j/PythonProcess.java:
##########
@@ -346,17 +352,33 @@ private void setupEnvironment() throws IOException {
final String command = String.join(" ", processBuilder.command());
logger.debug("Creating Python Virtual Environment {} using command {}", virtualEnvHome, command);
- final Process process = processBuilder.start();
+ final Process venvProcess = processBuilder.start();
- final int result;
try {
- result = process.waitFor();
+ // Wait for the venv creation with periodic checks for shutdown
+ // This allows the venv creation to be interrupted when the process is being shut down
+ while (!venvProcess.waitFor(1, TimeUnit.SECONDS)) {
+ if (isShutdown()) {
+ logger.info("Interrupting Python Virtual Environment creation due to shutdown");
Review Comment:
It would be helpful to include the Process ID in this log.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org