Slightly technical question for my friends on Planet GNOME. I have been hunting around for some help online with no luck, so I figured I would post here and hopefully this blog entry can be a solution for those who have similar questions.

I am in the process of porting App Of Jaq to to async. To do this I am using gio and have the code that downloads XML feeds up and running pretty well, and the app feels much more responsive. Now I need to have the application download an Ogg asynchronously without freezing the GUI.

My code currently looks like this:

def download_latest_shot(self):
    audiourl = "http://....the url to the Ogg file...."

    self.shot_stream = gio.File(audiourl)
    self.shot_stream.read_async(self.download_latest_shot_complete)

It then calls this callback:

def download_latest_shot_complete(self, gdaemonfile, result):
    f = self.shot_stream.read_finish(result).read()

    outputfile = open("/home/jono/Desktop/shot.ogg","w")
    outputfile.writelines(f)

Now, I am still pretty new to this, and while this code does work, it freezes the GUI pretty hard. Can anyone recommend some next steps for how I can download the file without it freezing? Some example code would be great. 🙂

Thanks in advance for anyone who can help. 🙂

Updates, Direct To Your Inbox

Updates, Direct To Your Inbox

Get the freshest posts with insights, approaches, tips, tricks, and recommendations delivered to you via email. Simple.

You have Successfully Subscribed!

Pin It on Pinterest

Shares
Share This