fix(sparql-anything): stop in-flight processes and clean up when the run is interrupted - #837
Open
ddeboer wants to merge 1 commit into
Open
fix(sparql-anything): stop in-flight processes and clean up when the run is interrupted#837ddeboer wants to merge 1 commit into
ddeboer wants to merge 1 commit into
Conversation
…run is interrupted - Listen for SIGINT and SIGTERM for the duration of a run; on either, stop the processes still going, remove the run directory, drop the listeners and re-raise the signal so the process exits as it would have - Each run registers its own listeners and removes only those, so parallel runs do not clobber each other - Document the behaviour under “Converting several chunks at once”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NativeTaskRunnerspawns each task withdetached: trueand nobody listened forSIGINT/SIGTERM, so interrupting the Node process – Ctrl-C during a long mapping, a cancelled CI job – left the JVMs running and thesparql-anything-*run directory behind.This takes the converter-level fix from the issue, since the converter is what knows which processes are in flight:
SparqlAnythingConverter.convert()registersSIGINT/SIGTERMlisteners for the duration of a run. On a signal it marks the run as failed (so no further chunk starts), stops the in-flight tasks through the existingstopInFlight()path, removes the run directory, removes its listeners and re-raises the signal withprocess.kill(process.pid, signal), so the default exit behaviour and exit code are preserved. A second signal while stopping is ignored.finally, so a completed run leaves none behind. Each run registers its own listener and removes only its own, so parallelconvert()calls do not clobber each other.NativeTaskRunner’s detached spawning is unchanged: its process-group kill instop()is what makes stopping work.process.killis stubbed so the test process survives.Fix #831