-
I'd like to add a time limit to my tasks such that they're terminated with a failure if the runtime of the task exceeds some threshold. It seems like that's currently left to the task to implement (e.g. check the task's own runtime inside of a loop and raise an exception if the threshold was exceeded). Is that correct? I didn't see an alternative to configure this in Procrastinate directly. For tasks that call into existing functions that may take significant time to complete (e.g. where I don't have direct access to the potentially long-running code) I suppose my only option is to spawn a subprocess (to run the compute intensive work) and then kill it from the parent if the time limit is reached. Would doing so interfere with Procrastinate itself? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
If the task is async, that's supposedly easily achievable with |
Beta Was this translation helpful? Give feedback.
If the task is async, that's supposedly easily achievable with
asyncio.wait_for
.If the task is sync, it's going to be more complicated. From what I can say, the 2 options are the subprocess (as you mentionned) or a signal handler on SIGALARM (and I have no idea whether this plays nicely with threads, given sync code is executed in threads.)