Skip to content

fix(sparql-anything): stop in-flight processes and clean up when the run is interrupted - #837

Open
ddeboer wants to merge 1 commit into
mainfrom
fix/converter-stops-on-signal
Open

fix(sparql-anything): stop in-flight processes and clean up when the run is interrupted#837
ddeboer wants to merge 1 commit into
mainfrom
fix/converter-stops-on-signal

Conversation

@ddeboer

@ddeboer ddeboer commented Sep 8, 2026

Copy link
Copy Markdown
Member

NativeTaskRunner spawns each task with detached: true and nobody listened for SIGINT/SIGTERM, so interrupting the Node process – Ctrl-C during a long mapping, a cancelled CI job – left the JVMs running and the sparql-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() registers SIGINT/SIGTERM listeners 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 existing stopInFlight() path, removes the run directory, removes its listeners and re-raises the signal with process.kill(process.pid, signal), so the default exit behaviour and exit code are preserved. A second signal while stopping is ignored.
  • The listeners are removed in the existing finally, so a completed run leaves none behind. Each run registers its own listener and removes only its own, so parallel convert() calls do not clobber each other.
  • NativeTaskRunner’s detached spawning is unchanged: its process-group kill in stop() is what makes stopping work.
  • Tests with the package’s fake task runner cover: interruption stops every in-flight task, removes the run directory and the listener before the signal is re-raised; a repeated signal; a run still going after another finished; and no listener left after normal completion. process.kill is stubbed so the test process survives.
  • Docs: a paragraph under “Converting several chunks at once”.

Fix #831

…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”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

task-runner-native: tasks outlive the process on SIGINT/SIGTERM

1 participant