sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Enhancement: signal to end processing early e.g. via AbortController API

Open dmitrizzle opened this issue 1 year ago • 2 comments

I couldn't find anything in the docs or in the repo except for the timeout option. However, I'd like to kill the process while it's still happening (for example, if the user requests the process to be stopped, I would like to free up the memory).

I've noticed that there's _vips_shutdown() being used internally and I wonder if this function does the above?

dmitrizzle avatar Feb 13 '25 09:02 dmitrizzle

Given the multi-threaded nature of image processing we can't stop things immediately but it might be possible to set a flag that says "stop when all running threads have joined" and periodically check that. I'm unsure how we'd get this info across the JavaScript/C++ divide most efficiently so this would require some experimentation.

In terms of API, something like an AbortController would make sense.

This partly relates to #2189 - it might be possible to implement both via the same means.

lovell avatar Feb 28 '25 20:02 lovell

Ah, thank you. I am currently planning to kill the entire container when the job is complete to be safe.

dmitrizzle avatar Mar 06 '25 20:03 dmitrizzle