Created
February 13, 2014 16:38
-
-
Save gleero/8978658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gi.repository import GLib, Gio, GObject | |
import time | |
def slow_stuff(job, cancellable, user_data): | |
print "Slow!" | |
for i in xrange(5): | |
print "doing slow stuff..." | |
time.sleep(0.5) | |
print "finished doing slow stuff!" | |
return False # job completed | |
def main(): | |
GObject.threads_init() | |
print "Starting..." | |
Gio.io_scheduler_push_job(slow_stuff, None, GLib.PRIORITY_DEFAULT, None) | |
print "It's running async..." | |
GLib.idle_add(ui_stuff) | |
GLib.MainLoop().run() | |
def ui_stuff(): | |
print "This is the UI doing stuff..." | |
time.sleep(1) | |
return True | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment