Wesley Henwood wrote: > I've checked and double checked my code and I am closing all files > explicitly after opening them. The only possibliy I can think of is > Python opening files each time I run a script, or each time imput to > stderr or stdout is redirected. > <snip>
The problem >I think< is that stout and stderr are not shared with each invocation. Since you're calling a python interpreter, the stdout/stderr from the C++ program is not inherited - so now everytime you call the python script, it's creating a new process. With each new process, you're creating a new stdout/stderr handle, and if you're calling outside of C++ relatively quickly (say more than 100 times a minute), then the old stdout/stderr handles have not had a chance to be garbage collected - hence, you get too many files open errors. The workaround would possibly be to create a Python thread or create a stdout fifo and a stderr fifo and have your script redirect these outputs through the fifo buffers that you're C++ code can listen to. Not sure how to do either one in MS environments, so you'll have to ask someone else how to work with them. -- http://mail.python.org/mailman/listinfo/python-list