pablo.yabo at gmail.com
Tue Sep 4 14:50:46 CEST 2007
Thank you for your response, it's difficult to get an answer on this
I 'solved' the issue in that way. When I enter to any function of my library
I release the interpreter lock and then I get it again.
It's not the best solution but it's acceptable. The problem is that Python
code cannot use any native wait or suspend function.
I wonder if why this issue is not fixed.
On 9/4/07, Hrvoje Niksic <hniksic at xemacs.org> wrote:
> "Pablo Yabo" <pablo.yabo at gmail.com> writes:
> > The problem is that I having problems with threads. I saw that I
> > have to PyEval_InitThreads and then PyThreadState_New and
> > PyThreadState_Swap from the new thread but this way to solve the
> > problem doesn't work for me because I need to let 2 or more threads
> > run at the SAME time.
> I don't know if this is still relevant, but it occurs to me that what
> you want might be accomplished. If your external library is
> thread-safe, and if you're only using Python to manipulate data
> managed by the library, you can simply Py_BEGIN_ALLOW_THREADS and
> Py_END_ALLOW_THREADS when entering the library. That way all calls
> from Python into the library will run with threading enabled, while
> the part spent in the interpreter (outside the library entry points)
> will continue to run single thread at a time. Python sources often
> use this pattern when dealing with IO-bound (e.g. the file and socket
> API) or CPU-bound code.
> Is such a solution acceptable for you?
More information about the capi-sig