Python ElementTree.parse() from file does not close the file -
I have an XML file - type the template type and make a request (fill some data) to fill in the parameters.
I
tree = ET Open this file with pars (path_to_file) and I loop to get XML from it, fill the file with the parameter and send a request. But after 2555 requests I receive an error message:
IOError: [Errno 24] Very open files: 'resource / CMR / skeleton / man / CreateLiveEvent.xml' Is there a way to close the file after ET? PRA () opens it?
Thanks
Upgrade your 2.7 installation to estimate, and 2.7.3 Was involved in. does it seems that the way the cElementTree closes the implementation files (as it does not turn them off), there is a bug in it.
The alternative file is to open:
with opening (path_to_file, 'rb') as xml_file: tree = et.parse (xml_file) and leave this file object to close with statement file as binary ; This is the work of XML parser to handle the end of the line and the encoding.
Comments
Post a Comment