Non blocking wait in python

前端 未结 4 1470
忘掉有多难
忘掉有多难 2021-01-04 05:43

in python, if i want to keep a process or thread running forever, i can typically do this with an empty while loop:

while 1:
    pass
         


        
4条回答
  •  迷失自我
    2021-01-04 06:23

    Don't use busy waiting. Depending on what you are waiting for, use one of the operating system's blocking wait functions, e.g. select on Unix and WaitForSingleObject/WaitForMultipleObjects on Windows.

提交回复
热议问题