How to break time.sleep() in a python concurrent.futures

后端 未结 3 877
渐次进展
渐次进展 2021-02-15 23:29

I am playing around with concurrent.futures.

Currently my future calls time.sleep(secs).

It seems that Future.cancel() does less than I thought.

3条回答
  •  -上瘾入骨i
    2021-02-16 00:09

    I do not know much about concurrent.futures, but you can use this logic to break the time. Use a loop instead of sleep.time() or wait()

    for i in range(sec):
        sleep(1)
    

    interrupt or break can be used to come out of loop.

提交回复
热议问题