Opened 10 years ago

Closed 8 years ago

#8058 closed Bugs (fixed)

boost::python::exec_file not closing file descriptor with python 2.7

Reported by: shobhit87@… Owned by: Stefan Seefeld
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

I am trying to execute a python script in my c++ code using python2.7 and boost1.47.0

Here is the code:

#include "boost/python.hpp"
#include <iostream>

int main(int argc, char** argv)
{
    Py_Initialize();
    boost::python::object test = boost::python::import("__main__");
    boost::python::object testDict = test.attr("__dict__");
    while (1){
    try
    {
        boost::python::exec_file("test.py", testDict, testDict);
    }
    catch(boost::python::error_already_set& e)
    {
        PyErr_Print();
    }
    catch(std::exception const &exc)
    {
        std::cerr << exc.what();
        PyErr_Print();
        _exit(0);
    }
 }
Py_Finalize();
return 0;
}

It is working fine with python2.4 and boost1.34.1(on both 32 bits and 64 bits machine). But on 64 bit machine it is not closing the file descriptor with python2.7. After crossing the maximum FD limit(i.e. ulimit value) its crashing with the following error:

test.py : no such fileIOError: [Errno 24] Too many open files: 'test.py'

Change History (4)

comment:1 by viboes, 10 years ago

Component: NonePython
Owner: set to Ralf W. Grosse-Kunstleve

comment:2 by Mikhail Matrosov <mikhail.matrosov@…>, 8 years ago

Fixed in pull request #15 (cannot attach a link :-/ )

comment:3 by Stefan Seefeld, 8 years ago

Owner: changed from Ralf W. Grosse-Kunstleve to Stefan Seefeld

comment:4 by Stefan Seefeld, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.