[QGIS-Developer] Error 32 (File is in Use): Trying to delete a layer file after it's been used by qgis

Matheus Fillipe matheusfillipeag at gmail.com
Mon Oct 14 14:32:29 PDT 2019


Hello!

I am working on a plugin that uses a temporary folder to load layer filers on that can end up having the same name so it is needed to have qgis closing the files to allow deleting them. I tested this on qgis 3.8.3 and for linux it worked fine but on windows still gives "error 32 , cannot remove because the file is in use".

process(l)
l.commitChanges()
l.endEditCommand()
QgsProject.instance().removeMapLayer(l.id())
path=l.dataProvider().dataSourceUri().split("|layername=")[0]
Path(path).unlink() #remove file returns file being used error on this line

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20191014/78bc079c/attachment.html>


More information about the QGIS-Developer mailing list