I am using OmniThread Parallel.foreach(). There are instances where the loop takes a long time or gets stuck.
I would like to know, is it possible to timeout each process in the Parallel.foreach() loop?
I am using OmniThread Parallel.foreach(). There are instances where the loop takes a long time or gets stuck.
I would like to know, is it possible to timeout each process in the Parallel.foreach() loop?
In short: Nope, there isn't.
Unless you program the timeout handling in your 'thread body' code (what gets called in the execute).
eg my database engine allows sending a
CancelProcessingcall to running queries from a different thread that runs the query, this would 'cleanly' end the running subthread.'Dirty' end of the subthreads:
I added a FR to Omnithread's github site to add an (Dirty)
Terminatemethod to theIOmniParallelinterfaces (and alikes). Which has is drawback because killing subthreads will probably leave you with memory/resource leaks.Meanwile you might use this dirty shutdown solution/workaround wich actually comes down fixing a similar problem (I had a deadlock in my parallel processed routine, so my
parallel.Waitfornever returned true, and worse myIOmniParallelTaskinterface variable was never released causing the calling thread to block as well.