My react front end uses an abortController to signal when the useFetch hook is unmounted (if the url changes, if the page is refreshed etc). While the data is no longer being received on the front end, I believe that the request is still being processed by the flask backend (spun up by gunicorn).
My question is - is there an elegant or common way to cancel the flask request? Some of my requests deal with large chunks of data being queried from the database (resulting in tens of seconds of wait time) and I would like those to cancel instead of run through and steal API time and memory.
I have seen this stack overflow: Stop processing Flask route if request aborted but it was 9 years ago. I also read through Flask: What happens when a user closes the browser while a long process is being executed? - I was wondering if there is a better way to approach the problem 10 years later since this most recent post from 2021 references the older post.