In there something similar to Java's Thread.yield() in Python? Does that even make sense?

后端 未结 3 1715
广开言路
广开言路 2021-02-15 13:24

I want to tell my Python threads to yield, and so avoid hogging the CPU unnecessarily. In Java, you could do that using the Thread.yield() function. I don\'t think

3条回答
  •  野性不改
    2021-02-15 13:46

    Dup of: How does a threading.Thread yield the rest of its quantum in Python?.

    time.sleep(0)
    

提交回复
热议问题