Re: Best way to busy-wait in Python 3 / Gtk+ 3?
- From: Michael Torrie <torriem gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Best way to busy-wait in Python 3 / Gtk+ 3?
- Date: Sun, 07 Oct 2012 22:10:08 -0600
On 10/07/2012 08:41 PM, Simon Feltman wrote:
On Sun, Oct 7, 2012 at 12:29 PM, Filip Lamparski
<matka poohatka gmail com> wrote:
On 7 October 2012 12:58, <jcupitt gmail com> wrote:
To have the load in another process, use a pipe to send worker results
back to the main process, and add the pipe to your gtk main loop as an
event source.
Is there any way I could do that? I looked at GLib's main loop and Gtk's
main loop, but can't seem to find it.
Is the idea to have a first pass downloading image files in a separate
process and then use a thread to load them into memory? I don't know
much about GStreamer but it seems like it might be helpful technology
in this realm.
For completeness, you can use pythons multiprocessing module along
with GLib's io watch:
parent, child = multiprocessing.Pipe()
GLib.io_add_watch(parent, GLib.IOCondition.IN, event_callback)
process = multiprocessing.Process(target=worker_func, args=(child,))
process.start()
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]