Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-22 Thread simon zhang
But I don't call Py_Initialize().I call C++ code in Python.Don't embed the Python to C++... 2012/12/23 Jaedyn K. Draper > Instead of Py_Initialize() (wherever it is you call it), try calling > Py_InitializeEx(0). Py_Initialize() (or Py_InitializeEx(1)) binds signal > handlers (including SIGIN

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-22 Thread Jaedyn K. Draper
Instead of Py_Initialize() (wherever it is you call it), try calling Py_InitializeEx(0). Py_Initialize() (or Py_InitializeEx(1)) binds signal handlers (including SIGINT) to send python exceptions instead of killing the process. This may be what's hitting you. On 12/23/2012 1:44 AM, simon zhang

[C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-22 Thread simon zhang
I have make a boost.python module with an endless loop.But I can't kill the process by ctrl-c.The following is an example. C++ #include #include #include #include usring namespace boost::python; void foo() { int it=0; while (true) { //endless loop ++it; st

Re: [C++-sig] Trouble destructor, call python's object with pointer in boost.python

2012-12-22 Thread Jaedyn K. Draper
No problem! On 12/22/2012 5:08 PM, simon zhang wrote: You are right.Thank you. 2012/12/23 Jaedyn K. Draper > If you pass it to a function like that, it passes it by value even if it's a pointer. So it's calling the copy constructor (which you haven'

Re: [C++-sig] Trouble destructor, call python's object with pointer in boost.python

2012-12-22 Thread simon zhang
You are right.Thank you. 2012/12/23 Jaedyn K. Draper > If you pass it to a function like that, it passes it by value even if > it's a pointer. So it's calling the copy constructor (which you haven't > defined so it isn't printing "A start"), rather than the regular > constructor, and then destr

Re: [C++-sig] Trouble destructor, call python's object with pointer in boost.python

2012-12-22 Thread Jaedyn K. Draper
If you pass it to a function like that, it passes it by value even if it's a pointer. So it's calling the copy constructor (which you haven't defined so it isn't printing "A start"), rather than the regular constructor, and then destructing it. To pass an actual pointer rather than sending it

[C++-sig] Trouble destructor, call python's object with pointer in boost.python

2012-12-22 Thread simon zhang
when I call python's function with pointer as an argument in boost.python, there are some troubles in destructor. The following is a sample code #include #include #include #include #include using namespace boost::python; class A {public: A() { std::cout<< "A start"< ("A",init<>())