On Tue, 4 Sep 2018 at 02:56, Martin Isenburg <[email protected]> wrote:
>
> 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]

I think you need a:

output.wait()

after this line. See
https://stackoverflow.com/questions/23279941/closing-stdin-in-subprocess-popen

Nyall


>
> _______________________________________________
> QGIS-Developer mailing list
> [email protected]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to