Programmatically stop a request

Hi,

at work we have some requests that do take forever to finish, so much that by that time the frontend already killed the connection and thus, no matter if the request finishes or not, the user will not see the result.

Is there any way that, given a thread that is processing a request and some logic to know if it can be cancelled, a thread can be stopped and freed?

I also posted it on Stackoverflow with some more detail:

I'm not sure it will work ununaltered in Zope but this is designed to handle this case

To hook in you may be able to steel ideas/code how to hook in a request and monitor how long it takes from https://github.com/collective/haufe.requestmonitoring/blob/master/haufe/requestmonitoring/monitor.py

I'am not sure how difficult it is to add some functionality to interrupt the thread in a way it does not die completly.