guettli
guettli

Reputation: 27806

Individual timeouts for concurrent.futures

I see two ways to specify timeouts in concurrent.futures.

Both methods handle N running futures.

I would like to specify an individual timeout for each future.

Use Case:

How do I handle this with concurrent.futures? Or is this library not the right tool?

Conclusion

Upvotes: 14

Views: 1020

Answers (1)

mdurant
mdurant

Reputation: 28683

How about implementing your own:

wait(dbfutures + httpfutures, timeout=0.5)
[fut.cancel() for fut in bdfutures if not fut.done()]
wait(httpfutures, timeout=0.7)
[fut.cancel() for fut in httpfutures if not fut.done()]

(or a while loop with sleep/check or wait with short timeout)

Upvotes: 4

Related Questions