ViktorC / PP4J

A multiprocessing library for Java that features process pool implementations and a flexible API.
Apache License 2.0
32 stars 6 forks source link

Question about updateSubmissionQueue() #10

Open dmascle opened 4 years ago

dmascle commented 4 years ago

Hi again,

Firstly, thank you again for helping me on previous topic about JavaProcess.exit() !

Still on that topic, I had another question actually...

While making some tests, I realized that in some rare cases, when there is a crash in C++ part, it may terminates the Java.exe process without throwing any exception to the Java part (I suppose it depends how much the memory is corrupted...).

Problem is that is such situation, I can't throw any exception to cancel the task "Submission" and now the issue I have is coming from this part of code in InternalProcessExecutor.updateSubmissionQueue(InternalSubmission<?> submission): // If the execute method failed and there was no exception thrown, put the submission back into the queue at the front. submission.setThread(null); submissionQueue.addFirst(submission);

Because of this and because the Submission is not considered as finished, it rerun it again and the process terminates again, and rerun it, etc... forever.

Actually, I am not sure what should be done here, because I understand what was the purpose of this part of code. However, I think it would help me if I could configure the ProcessExecutor behavior to cancel Submission and raise an exception if for any reason the Process that was running it terminates with an error code.

What do you think ?

Thank you !

dmascle commented 4 years ago

I made a few tests by modifying the lib code on the fly and maybe an idea would be to modify this part of code in InternalProcessExecutor.waitForAndExecuteAvailableSubmission(): catch (DisruptedExecutionException e) { // The submission is not assumed to be at fault. }

Here, it would be nice to maybe add a test on a flag that would give the possibility to set the exception on the Submission, like: catch (DisruptedExecutionException e) { if(flagToCreate) submission.setException(e); }