简体   繁体   中英

time.sleep(5) will make entire program to sleep?

In my program, i have to wait for some installations to complete. The following is the pseudo Code for the same:

    Clock.schedule_once(self.instantiate_module1,2)
    Clock.schedule_once(self.instantiate_module2,2)
    while (instantiation is not done)
          time.sleep(4)

    Continue Execution
But the installations are never done.

Here sleep will keep the entire program(if we have multiple threads) to pause/sleep? How sleep method works?

time.sleep is blocking the main thread, where the clock also runs. A simple solution is to just clock schedule your checking function every four seconds instead, and cancel it when the installation finishes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM