Re: [C++-sig] X-language polymorphism and multithreading
On Saturday 03 July 2010 03:03:53 Anton Yabchinskiy wrote: > So, I need PyGILState_Ensure/PyGILState_Release around the > overridden method call, and PyEval_InitThreads in the module > initialization. Am I right? Is the following code OK? The code looks OK to me at least, but what's your problem? (You just wrote "does not work"!) Is there still a problem with the code below? If so, I can see potential problems just due to ownership handling, for example you pass &data to the callbacks, but who's the owner of that data? Is it possible that another thread releases the memory while the callback is running? Oh, I see another likely problematic thing: > void > on_data(const Data_Buffer& data) > { > if (override on_data = get_override("on_data")) { > GIL_State_Guard guard; > > on_data(data); > } > default_on_data(data); > } You're calling get_override - although I never used it, I believe it performs some PyObject_GetAttr or similar to check for an overridden method. Remember: As soon as you're dealing with any python objects, you need the GIL! (A common problem is that people don't see _GetItem oder _GetAttr as "running python code", although that's pushing your luck!) HTH, Hans ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
[C++-sig] Cannot build Boost.Python
Hi I am new to Boost.Python and am trying to build its library using Visual C++ 2008 on Windows XP. I have downloaded and unzipped boost_1_43_0.zip and I have installed boost-jam-3.1.18-1-ntx86.zip. Next, I executed: C:\boost_1_43_0\libs\python\example\quickstart>\boost-jam-3.1.18-1-ntx86\bjam toolset=msvc --verbose-test test The output I get is: == [snip] msvc.link bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe LINK : warning LNK4001: no object files specified; libraries used LINK : error LNK2001: unresolved external symbol _mainCRTStartup bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe : fatal error LNK1120: 1 unresolved externals call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 >nul link /NOLOGO /INCREMENTAL:NO /DEBUG /MACHINE:X86 /subsystem:console /out:"bin\test_embed.test\msvc-10.0\debug\threading-multi\test_em t_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe.rsp" if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% ...failed msvc.link bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.exe bin\test_embed.test\msvc-10.0\debug\threading- ...removing bin\test_embed.test\msvc-10.0\debug\threading-multi\test_embed.pdb ...skipped test_embed.run for lack of ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] X-language polymorphism and multithreading
On 2010-07-03 05:03:53+0400, Anton Yabchinskiy wrote: > So, I need PyGILState_Ensure/PyGILState_Release around the > overridden method call, and PyEval_InitThreads in the module > initialization. Am I right? Is the following code OK? With the GIL stuff code runs nicely now. It used to hang in the callback, but that was my fault: I forgot to export one of the types properly. I've just asked to be sure that I'm getting it right. Charles, Hans, thanks for the valuable information. ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig