multi-threaded c++ callback problem
hi all,
i'm building a wrapper for a multi-threaded c++ library to use it in python.
everything works fine except the callback.
the c++ code to call the python function:
//---//
void pyCallEventCallback( CALL hCall,
LINE hLine,
CALLSTATE_MAJOR eMajor,
CALLSTATE_MINOR eMinor,
PyObject* def )
{
if( !PyCallable_Check( def ) )
{
PyErr_SetString( PyExc_TypeError, "Need a callable object!" );
return;
}
printf( "EventCallback hCall: %i, hLine: %i, eMajor: %i, eMinor: %i\n",
hCall, hLine, eMajor, eMinor);
PyObject* arglist = Py_BuildValue("()", hCall, hLine, eMajor, eMinor);
// if i comment out next line it works!
PyEval_CallObject( def, arglist );
Py_XDECREF(arglist);
}
//---//
the python callback function looks like this:
//---//
def callback( *args ):
print "callback:", args
//---//
the soutput i get looks like this:
EventCallback hCall: 1, hLine: 1, eMajor: 2000, eMinor: 2001
callback: ( 1, 1, 2000, 2001 )
EventCallback hCall: 1, hLine: 1, eMajor: 2500, eMinor: 2501
callback: ( 1, 1, 2500, 2501 )
EventCallback hCall: 1, hLine: 1, eMajor: 8000, eMinor: 8001
an then instead of: callback: ( 1, 1, 8000, 8001)
it crashes
there are no other python interactions between the callback calls.
--
http://mail.python.org/mailman/listinfo/python-list
Python Forum
Hello, I would like to let the community know that there is a new web-based forum for Python enthusiasts over at PythonForum.org (http:// pythonforum.org). Web-based forums is a preferred method by Python newcomers to get help in exploring the world of Python and programming overall. The main goal of PythonForum.org is to popularize Python by welcoming all newcomers. Recently the forum got "attacked" with questions by users just starting out with Python. I hope here will be someone ready to welcome and help newcomers to enter the beautiful world of Python. Thank you, Einars -- http://mail.python.org/mailman/listinfo/python-list
extending class static members and inheritance
Hi All, I have a question. Let says I have the following two classes: class Base(object): __mylist__ = ["value1", "value2"] def somemethod(self): pass class Derived(Base): __mylist__ = ["value3", "value4"] def anothermethod(self): pass what I would like to accomplish is that the class Derived has the member __mylist__ extended or merged as ["value1", "value2", "value3", "value4"]. Is there anyway I could accomplish this? I was thinking on accomplishing this as follows: class Derived(Base): __mylist__ = Base.__mylist__ + ["value3", "value4"] def anothermethod(self): pass Is there a better way? Perhaps a decorator? Thanks in advance and regards, Fabian -- http://mail.python.org/mailman/listinfo/python-list
Different cache filename
Hi, when load a module "mymodule.py" with importlib.machinery.SourceFileLoader a bytecode file is created as mymodule.cpython-33.pyc. If I load a module "mymodule.ext.py" the same way the same bytecode file is created as mymodule.cpython-33.pyc. Is there any way I could tell python to generate the bycode file as mymodule.ext.cpython-33.pyc? Regards, Fabian -- http://mail.python.org/mailman/listinfo/python-list
