Author grahamd
Recipients amaury.forgeotdarc, grahamd, loewis, ncoghlan, pitrou
Date 2011-01-15.20:15:40
SpamBayes Score 7.77156e-16
Marked as misclassified No
Message-id <1295122543.7.0.0369609684868.issue10915@psf.upfronthosting.co.za>
In-reply-to
Content
Can you please provide an example of what user would do and what changes existing extension modules would need to make?

When I looked at this exact problem some time back, I worked out that you probably only need a single new public API function. This would be something like PyInterpreterState_Swap().

By default stuff would work on the main interpreter, but if for a specific thread it wanted to operate in context of a different sub interpreter, would call PyInterpreterState_Swap() to indicate that. That would store in TLS outside of any existing data structures. Functions like existing PyGILState_Ensure()/PyGILState_Release() would then look up that TLS variable to know which interpreter they are working with.

Doing it this way meant that no C extension modules using PyGILState_??? functions would need to change at all, as what interpreter is being operated on dictated by who created the thread and initiated call in to Python interpreter.

You probably want validation checks to say that PyInterpreterState_Swap() can only be called when not GIL lock held.

It worries me that you are talking about new PyGILState_??? functions as that would suggest to me that extension modules would need to change to be aware of this stuff. That you are saying that sqlite needs changes is what makes me things the way you are going is a problem. It isn't practical to make SWIG change to use something other than PyGILState_Ensure()/PyGILState_Release(), it should be transparent and required no changes to existing C extensions.
History
Date User Action Args
2011-01-15 20:15:43grahamdsetrecipients: + grahamd, loewis, amaury.forgeotdarc, ncoghlan, pitrou
2011-01-15 20:15:43grahamdsetmessageid: <1295122543.7.0.0369609684868.issue10915@psf.upfronthosting.co.za>
2011-01-15 20:15:40grahamdlinkissue10915 messages
2011-01-15 20:15:40grahamdcreate