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 wrote:
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  <boost/python.hpp>
#include  <boost/python.module.hpp>
#include  <boost/python.def.hpp>
#include  <iostream>
usringnamespace  boost::python;

void  foo()  {
    int  it=0;
    while  (true)  {                      //endless loop
        ++it;
        std::cout<<  it<<std::endl;
        sleep(3);
    }
}

BOOST_PYTHON_MODULE(ctopy)
{
     def("foo",foo);
}|

python:

|import  ctopy
ctopy.foo()|

result:

|1
2
3
4
.....................|

I can't kill the foreground process by Ctrl-c.why the module don't accept signal "SIGINT" that was sent by Ctrl-c.How to make it work.



_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to