[QGIS-Developer] Python ResourceWarning: unclosed file in Processing Plugin

Martin Isenburg martin.isenburg at gmail.com
Mon Sep 3 09:56:18 PDT 2018


Hello,

as soon as I run any of my LAStools plugin scripts I get the WARNING
"ResourceWarning" about an "unclosed file" shown below in the Python
warning window. I use the call "output = subprocess.Popen(....)" to get the
stderr output from the process so I can push it to the console once the
subprocess is complete with
the feedback.pushConsoleInfo(output.decode("utf-8")). Is it bad? Can I fix
it? Should I ignore it?

Complete code:

https://github.com/rapidlasso/LAStoolsPluginQGIS3/blob/master/LAStools/LAStoolsUtils.py

Regards.

Martin

2018-09-03T18:34:08     WARNING
warning:C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsUtils.py:60:
ResourceWarning:

             unclosed file

             traceback: File
"C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsPipelines\flightlinesToDTMandSpikeFreeDSM.py",
line 82, in processAlgorithm
              LAStoolsUtils.runLAStools(commands, feedback)
              File
"C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsUtils.py",
line 60, in runLAStools
              output = subprocess.Popen(commandline, shell=True,
stdout=subprocess.PIPE, stdin=open(os.devnull), stderr=subprocess.STDOUT,
universal_newlines=False).communicate()[0]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180903/0b320210/attachment.html>


More information about the QGIS-Developer mailing list