python - Individual timeouts for concurrent.futures -
i see 2 ways specify timeouts in concurrent.futures
.
as_completed()
wait()
both methods handle n running futures.
i specify individual timeout each future.
use case:
- future getting data db has timeout of 0.5 secs.
- future getting data http server has timeout of 1.2 secs.
how handle concurrent.futures
? or library not right tool?
conclusion
- afaik solution mdurant work-around.
- i think use different library next time. maybe asyncio has better support this. see: https://docs.python.org/3/library/asyncio-task.html#asyncio.sleep
how implementing own:
wait(dbfutures + httpfutures, timeout=0.5) [fut.cancel() fut in bdfutures if not fut.done()] wait(httpfutures, timeout=0.7) [fut.cancel() fut in httpfutures if not fut.done()]
(or while loop sleep/check or wait short timeout)
Comments
Post a Comment