Re: Best way to busy-wait in Python 3 / Gtk+ 3?
- From: Simon Feltman <s feltman gmail com>
- To: Michael Torrie <torriem gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Best way to busy-wait in Python 3 / Gtk+ 3?
- Date: Mon, 8 Oct 2012 00:32:16 -0700
On Sun, Oct 7, 2012 at 9:10 PM, Michael Torrie <torriem gmail com> wrote:
Maybe the best way is to avoid processes or threads altogether. Since
downloading this thumbnail is io-bound, not cpu-bound, once you send off
your request, just use io watches to trigger the main loop when
something has come in.
Agreed, better yet, the code could become much simpler using an async pixbuf:
def on_image_ready(stream, res, user_data):
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(res)
...
file = Gio.File.new_for_uri("...")
GdkPixbuf.Pixbuf.new_from_stream_async(file.read(None), None,
on_image_ready, None)
All within a main loop of course.
-Simon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]