Open Deadly0 opened 3 years ago
Hi! I suppose you're talking about thread pools. No, there is currently no out-of-the-box solution to this.
Do you mean killing the whole worker and spawning a new one if some task runs longer than the timeout? That feels a bit radical… 😅
I wonder if it's not usually a better idea to let the worker make sure to not spend an infinite amount of time on anything it does.
I have the following use case: I use threads.js inside a Node.js server (based on Express.js) to execute several client requests in parallel. Unfortunately, the complexity of the request is defined by request parameters in a pretty complex way, which doesn't allow me to predict processing time in advance. Moreover, most time the processing in threads happens inside third-party JS libraries, which prevents stopping processing from inside the thread...
So, the only solution for my use case I see is to kill a thread with too long request and spawn a new one. I agree that it's pretty radical behaviour. Also, it leads to some overall performance degradation because of thread spawning overhead.
Hi, is it possible to set timeout for task execution by which the task will be forcibly terminated?