Boost C++ Libraries: Ticket #11025: exec_file raises error if run in loop https://svn.boost.org/trac10/ticket/11025 <p> We tried to run a soak test of our code which uses boost::python, but found that after 509 runs the file could not be read. Found the cause to be boost::python not closing the FILE after an fopen. Line 91 in exec.cpp. Adding fclose(fs) after PyRun_File seemed to fix the problem. You can reproduce the problem with the following code: </p> <pre class="wiki">int _tmain(int argc, _TCHAR* argv[]) { int count = 0; Py_Initialize(); while (true) { auto strScriptFile = "D:\\Scrap\\ConsoleApplication2\\SampleCustomMacroOne.py"; object main_module = import("__main__"); dict globalDict = extract&lt;dict&gt;(main_module.attr("__dict__")); exec_file(strScriptFile, globalDict); std::cout &lt;&lt; count &lt;&lt; endl; count++; } return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11025 Trac 1.4.3 Stefan Seefeld Thu, 26 Mar 2015 12:47:48 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11025#comment:1 https://svn.boost.org/trac10/ticket/11025#comment:1 <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">duplicate</span> </li> </ul> <p> This is a duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8058" title="#8058: Bugs: boost::python::exec_file not closing file descriptor with python 2.7 (closed: fixed)">#8058</a> </p> Ticket