This post has been archived and may contain out of date or no longer relevant information.

Python Wait Function – Alternative to Sleep for GTK

I hate sleep functions. In GTK, for example, they lock the UI making it unusable and even make some systems think that the program is hanging (which in essence it is). Here is a quick “wait” function written in Python.

As I was waiting for something to install I came up with this idea and quickly decided to write it. Instead of sleeping it runs an unproductive while loop. This has so far stopped programs and UI such as GTK locking up.

GTK Example

def wait(time_lapse):
time_start = time.time()
time_end = (time_start + time_lapse)

while time_end > time.time():
while gtk.events_pending():
gtk.main_iteration()