Re: Gtk, Python, and Threading.



Hi Robert,

are you following the advice in the faq?

http://faq.pygtk.org/index.py?file=faq20.001.htp&req=show

Also, the pygtk mailing list should be better for questions about
using pygtk, as opposed to developing it.

Cheers,

Tomeu

On Mon, Dec 13, 2010 at 04:56, Robert Park <rbpark exolucere ca> wrote:
> Hi hackers!
>
> Does anybody have any experience with threading in python/pygobject?
>
> Basically, I'm using json with urllib to download some information in
> the background (I don't want this action to block the UI for the user,
> as it's quite slow). So I have a simple class that inherits from
> threading.Thread and does all the work of downloading, and once the
> download is complete, it needs to insert it into a ListStore for
> display to the user.
>
> The code I have by and large works, but the problem I'm running into
> is that in order to get the information to display in the liststore,
> you have to click around a lot in the interface. What I mean is, if
> you initiate the thread and then just sit there and wait, nothing will
> appear to happen. but if I click around from one entry in the
> liststore to the next rapidly, that causes the data to appear, but
> slowly (it takes three to seven clicks to make each row display it's
> data). It's almost as if the background thread is blocked by the GTK
> main loop, and it requires clicking around to advance the loop and run
> the thread.
>
> However, if I comment out the call to ListStore.set_value(), it
> doesn't stop this happening. Even with just print statements (and
> absolutely no GTK code in the thread method), this behavior still
> happens.
>
> I also noticed that if I quit the program before the thread stops
> running, the rest of the thread successfully executes quite quickly
> just as the application window disappears.
>
> Does anybody have any thoughts on this? Am I doing something wrong? Is
> threading terrible? How can I do slow things in the background so the
> UI can remain responsive?
>
> Thanks.
>
> --
> http://exolucere.ca
> _______________________________________________
> python-hackers-list mailing list
> python-hackers-list gnome org
> http://mail.gnome.org/mailman/listinfo/python-hackers-list
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]