Re: [gtk-osx-users] Lion, NSUserDefaults, Threading, Python and Deadlock?
- From: John Ralls <jralls ceridwen fremont ca us>
- To: Richard Procter <richard n procter gmail com>
- Cc: gtk-osx-users-list gnome org
- Subject: Re: [gtk-osx-users] Lion, NSUserDefaults, Threading, Python and Deadlock?
- Date: Tue, 13 Dec 2011 17:38:39 -0800
On Dec 13, 2011, at 3:45 PM, Richard Procter wrote:
>
> On 9/12/2011, at 1:53 PM, Richard Procter wrote:
>
>> Hi Everyone,
>>
>> My application has been freezing on Lion (call trace below). This is a tentative heads-up for anyone using pygtk and the NSUserDefaults system on Lion.
>
> I've fixed this now. Here's what I think was happening:
>
> I was wrong to believe (and after looking carefully at the pygobject and python code!) that pygtk was releasing the GIL lock upon entry to gtk.main(). Apparently an explicit call to gobject.init_threads() is required to enable pygtk release of the GIL, without which the deadlock I outlined is almost guaranteed.
>
> The problem appeared with Lion and I believe this is because Apple have added a new pthread work queue to handle NSUserDefaults synchronisation, which is consistent with their release notes. That thread called into python as a side-effect of releasing an object I had presumably passed through from python (via the PyObjC bridge) at some point, probably a python string literal.
>
> The lesson is: Lion implicitly forces multithreading on an ostensibly single-threaded pygtk application if you pass python parameters to AppKit.NSUserDefaults (provided by the PyObjC bridge to AppKit).
>
> And I wonder if Apple's seemingly benign and useful --- but complicating --- improvement has created a new class of potential problems for other software more generally?
Probably not. You're on extremely thin ice mixing PyObjC and PyGtk; I don't think that that's at all common.
This particular change isn't likely to affect *any* of the devs Apple cares about, who are the ones using Apple's tools to target only Snow Leopard and Lion.
I suspect that they'd like to discourage those of us floundering about with other frameworks, trying to support older versions of the OS (and hardware -- XCode 4 is missing the libraries for PPC). We're not helping them sell new Macs or iPads.
Regards,
John Ralls
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]