Boost C++ Libraries: Ticket #8058: boost::python::exec_file not closing file descriptor with python 2.7 https://svn.boost.org/trac10/ticket/8058 <p> I am trying to execute a python script in my c++ code using python2.7 and boost1.47.0 </p> <p> Here is the code: </p> <pre class="wiki"> #include "boost/python.hpp" #include &lt;iostream&gt; 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&amp; e) { PyErr_Print(); } catch(std::exception const &amp;exc) { std::cerr &lt;&lt; exc.what(); PyErr_Print(); _exit(0); } } Py_Finalize(); return 0; } </pre><p> 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: </p> <p> test.py : no such fileIOError: [Errno 24] Too many open files: 'test.py' </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8058 Trac 1.4.3 viboes Fri, 15 Feb 2013 17:18:44 GMT component changed; owner set https://svn.boost.org/trac10/ticket/8058#comment:1 https://svn.boost.org/trac10/ticket/8058#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ralf W. Grosse-Kunstleve</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Python</span> </li> </ul> Ticket Mikhail Matrosov <mikhail.matrosov@…> Tue, 10 Mar 2015 22:37:55 GMT <link>https://svn.boost.org/trac10/ticket/8058#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8058#comment:2</guid> <description> <p> Fixed in pull request <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/15" title="#15: Feature Requests: thread class needs join() with timeout (closed: None)">#15</a> (cannot attach a link :-/ ) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Stefan Seefeld</dc:creator> <pubDate>Thu, 26 Mar 2015 12:29:48 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/8058#comment:3 https://svn.boost.org/trac10/ticket/8058#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Ralf W. Grosse-Kunstleve</span> to <span class="trac-author">Stefan Seefeld</span> </li> </ul> Ticket Stefan Seefeld Thu, 26 Mar 2015 12:30:06 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8058#comment:4 https://svn.boost.org/trac10/ticket/8058#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket