[IPython-dev] A plea for help with a threading bug...

Fernando Perez Fernando.Perez at colorado.edu
Mon Mar 21 17:30:04 CST 2005


ipython-dev-bounces at scipy.net wrote:
> The attached message has been automatically discarded.

[ Originally sent by Yariv, reforwarded by me.  The non-quoted stuff are my 
questions.

I've whitelisted one address for you, but you might want to just subscribe if 
you use many.

f]

> ------------------------------------------------------------------------
> 
> Subject: Re: [Fwd: Re: [IPython-dev] A plea for help with a threading bug...]
> From: Yariv Ido <yariv at vipe.technion.ac.il>
> Date:  Sun, 20 Mar 2005 16:04:02 +0200
> To: Fernando Perez <Fernando.Perez at colorado.edu>
> CC: Yariv Ido <yariv at vipe.stud.technion.ac.il>, IPython-dev List 
> <ipython-dev at scipy.net>
> 
> 
> Hi,
> 
> Well, first of all, the self.gtk.threads_init() call should be made on
> win32 systems too. As far as I know, this isn't a platform specific
> hack...
> Second, in order to avoid lockups ( Which occur if you do call
> threads_init() on win32 ), you need to wrap the call to gtk's mainloop
> with threads_enter() and threads_leave() calls:
> 
> 					self.gtk.threads_enter()
>         self.gtk_mainloop()	->	self.gtk_mainloop()
> 					self.gtk.threads_leave()
> 
> In theory, every call to some gtk functionality made outside the main
> thread should also be wrapped with this lock mechanism. Unfortunately, I
> think it's not trivial in the case of IPython, especially when the user
> decides to create new threads which mess around with GTK's objects... I
> don't know what are the odds of that happening...

Well, I can at least wrap the calls _I_ make in the above.  I just tried it, 
and I see no ill effects.  As for protecting the user's calls, I don't know... 
  Unless someone tells me otherwise (I know so little about threads and GTK, 
that I rely on your collective wisdom here), this change will go into CVS.

> 
> There's a short explanation about all this at:
> <http://www.moeraki.com/pygtkreference/pygtk2reference/gdk-functions.html#function-gdk--threads-enter>
> 
> Y.
> 
> On Sat, 2005-03-19 at 12:53 -0700, Fernando Perez wrote:
> 
>>[Yariv]
>>
>>
>>>3. I've noticed that IPython's code has no
>>>threads_enter()/threads_leave(). I don't know if it would solve this
>>>particular problem, but it may fix the threads_init() call in win32 (And
>>>thus fix the tremendous slowdown as reported on the bug tracker).
>>
>>Could you be more specific on where this should go?  And is there anyway 
>>anyone could test this on win32 and let me know if it helps any?  I'll be 
>>happy to add the changes, but only if I know they will help, and where to put 
>>them.
>>
>>best,
>>
>>f




More information about the IPython-dev mailing list