<div dir="ltr"><div dir="ltr">Hello.<div><br></div><div>thanks for the suggestion. I tried this instead:</div><div><br></div><div><div> output = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull), stderr=subprocess.STDOUT, universal_newlines=False)</div><div> output.wait()</div><div> feedback.pushConsoleInfo(output.communicate()[0].decode("utf-8"))</div></div><div><br></div><div>but as soon as the subprocess is started (long before it completes) this WARNING is output to the console. </div><div><br></div><div><p style="margin:0px;white-space:pre-wrap"><span style="color:rgb(220,125,0)">2018-09-04T13:05:31 WARNING </span>warning:C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsUtils.py:60: ResourceWarning:<br> <br> unclosed file <br> <br> traceback: File "C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStools\lasview.py", line 67, in processAlgorithm<br> LAStoolsUtils.runLAStools(commands, feedback)<br> File "C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsUtils.py", line 60, in runLAStools<br> output = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull), stderr=subprocess.STDOUT, universal_newlines=False)</p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px;white-space:pre-wrap">how do others grab the stderr output off their subprocesses for display in the console?</p><p style="margin:0px;white-space:pre-wrap"><br></p><p style="margin:0px;white-space:pre-wrap">Martin</p></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 4, 2018 at 1:03 AM Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, 4 Sep 2018 at 02:56, Martin Isenburg <<a href="mailto:martin.isenburg@gmail.com" target="_blank">martin.isenburg@gmail.com</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> 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?<br>
><br>
> Complete code:<br>
><br>
> <a href="https://github.com/rapidlasso/LAStoolsPluginQGIS3/blob/master/LAStools/LAStoolsUtils.py" rel="noreferrer" target="_blank">https://github.com/rapidlasso/LAStoolsPluginQGIS3/blob/master/LAStools/LAStoolsUtils.py</a><br>
><br>
> Regards.<br>
><br>
> Martin<br>
><br>
> 2018-09-03T18:34:08 WARNING warning:C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsUtils.py:60: ResourceWarning:<br>
><br>
> unclosed file<br>
><br>
> traceback: File "C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsPipelines\flightlinesToDTMandSpikeFreeDSM.py", line 82, in processAlgorithm<br>
> LAStoolsUtils.runLAStools(commands, feedback)<br>
> File "C:/Users/isenburg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\LAStools\LAStoolsUtils.py", line 60, in runLAStools<br>
> output = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull), stderr=subprocess.STDOUT, universal_newlines=False).communicate()[0]<br>
<br>
I think you need a:<br>
<br>
output.wait()<br>
<br>
after this line. See<br>
<a href="https://stackoverflow.com/questions/23279941/closing-stdin-in-subprocess-popen" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/23279941/closing-stdin-in-subprocess-popen</a><br>
<br>
Nyall<br>
<br>
<br>
><br>
> _______________________________________________<br>
> QGIS-Developer mailing list<br>
> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>