On Mon, 2004-03-01 at 19:16, Christian Robottom Reis wrote:
> I agree, and it does sound like a bug to me. Gustavo seems to be
> concerned about [unconditionally?] locking around the Py_DECREF() call,
> which in this case suggests to me the best path is to open a bug report
> in bugzilla.gnome.org. If you could include your testcase and analysis
> above, it would be a great description for the bug, already.

ok, i'll do that

> > There aren't any threads in the example because I thought that would
> > make it harder to follow and they're not needed to exhibit the problem,
> > though the call to gtk.init_threads is needed to cause pygtk to attempt
> > to acquire & free the interpreter lock.
> 
> This is the part that confuses me. I asked before: if you do
> threads_init() at the beginning of the program (before creating the
> ListStore) do things work as expected? What does threads_init() do that
> makes Py_DECREF an operation that requires thread locking?

Moving the threads_init call to be the first non-import statement
doesn't remove the problem, sorry my example might have been clearer if
it had been that way.

My understanding, after browsing the pygtk source and stepping through
the pygtk code with a debugger, is that the gtk.threads_init() call
causes pygtk to modify its behaviour. Making this call causes pygtk to
grab the intrepreter lock when it calls python related code and then
release it when gtk calls are made.

> I wonder if a potential solution is to lock around the Py_DECREF()
> *when* threading is enabled?

I think this is what my suggested change does because the
pyg_block_threads & pyg_unblock_threads only result in the expensive
locking if gtk.threads_init() has been previously called.

Though I'm not sure if the pyobject_free call is being used in other
circumstances and so maybe the suggested change might be affecting other
situtations.

cheers,
Graham

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to