Hi,

I have some questions concerning the global interpreter lock:

I am working with Windows XP Professional Version 5.1, Python version 2.4.1
and Microsoft Visual C++.Net Version 7.1.
>From Python I call a function from a C++ dll using
calldll.call_foreign_function. This C++ function does a callback of a python
function.
Do get it running I use PyGILState_Ensure before PyEval_CallObject and
PyGILState_Release afterwards.
The code looks like this:

                                static PyObject *my_callback = NULL;
                                
                                ...

                                // my_callback is set from Python using a 
function SetCallback
                                ...

                                
                        /* Time to call the callback */
                        ppyobjArgList = Py_BuildValue("()", NULL);          
               
                        //General Interpreter Lock (essential for succesful
calling of any python function)
                        PyGILState_STATE gstate;
                        //Ensure that the current thread is ready to call
the Python C API 
                        gstate = PyGILState_Ensure();
                        
                        ppyobjResult = PyEval_CallObject(my_callback,
ppyobjArgList);
                        if (!((DWORD_PTR)ppyobjResult))
                        {
                                        //Error handling
                                        ...
                                } else {
                                        Py_DECREF(ppyobjResult);
                                }
 
                                Py_DECREF(ppyobjArgList);

                        PyGILState_Release(gstate);

Now my questions:
Are there any risks aquiring the global interpreter lock?
Do I invoke by PyEval_CallObject a new python process? (I suppose not)
How long my this call of PyEval_CallObject last? Are there restictions to
the code I use in the called function.
Is it allowed to force the thread to wait (by aquiring the GIL)?
Is there a risk that windows hangs up?
Doing several calls of my dll function with the callback, is there a risk
that the calls overlap and information gets lost?

Thanks for your help!
Ralf

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to