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

后端 未结 3 1641
深忆病人
深忆病人 2020-12-08 01:53

I\'ve got a thread that\'s polling a piece of hardware.

while not hardware_is_ready():
    pass
process_data_from_hardware()

But there are

3条回答
  •  [愿得一人]
    2020-12-08 02:46

    time.sleep(0) is sufficient to yield control -- no need to use a positive epsilon. Indeed, time.sleep(0) MEANS "yield to whatever other thread may be ready".

提交回复
热议问题