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?
- cleanly terminating a thread if it takes too long choltreppe
- cleanly terminating a thread if it takes too long guzba