Graham Dumpleton <graham.dumple...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10915>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to