Individual timeouts for concurrent.futures

后端 未结 1 475
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-11 10:51

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

  • as_completed()
  • wait()

Both methods handle N running

相关标签:
1条回答
  • 2021-01-11 10:56

    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)

    0 讨论(0)
提交回复
热议问题