> I suggest taking a different approach tbh. Could the work being done have a > timeout it checks as it tries to make progress, and if the timeout is > exceeded that causes it to just raise an exception or something?
There are multiple algorithms and most of them are quite complex. So I try to avoid having to place time checks everywhere. > Another issue, and what I suspect is the cause for you issues, is the fact > that you access global memory without locks and share data between threads > without any concerns about where it's freed. This likely causes some illegal > state which leaves your program spinning. The global data that I access is never written to (except once at program startup). I would have made them const if they werent recursive data types. So I dont think I could run into race conditions (?) and memory-leaks shouldnt be a problem either, since that data should live the whole program livespan anyways. Or did I missunderstood your concern and there are some other potential issues? > You could always set the cancellation type to asynchronous, to just have it > terminate anywhere. But you'd still need cleanup handlers. I still agree > though that handling this with an abort mechanism is much better. I will look into that. If thats too complicated I might take a complete different approach and compile the whole computation logic into a separate program that my server runs for every request. so I can savely just kill that process then.