How to close QgsRasterLayer's file handler, in Python script?

by Edgar Szilagyi   Last Updated May 16, 2019 02:22 AM

I'm creating a QgsRasterLayer from temporary file, as result from some processing algorithm. After that, I no longer can delete file, as expected. But, because It is only a temp file, I need delete It after all my processing is done. I tried, without success:

layer = QgsRasterLayer("myTempFile.tif")

#Do some work...

del layer

myTempFile.tif still can't be deleted, but only after closing QGIS.

Tags : pyqgis

Related Questions

Updated September 29, 2018 02:22 AM

Updated January 10, 2019 15:22 PM

Updated January 16, 2019 00:22 AM

Updated January 20, 2019 15:22 PM

Updated May 15, 2019 21:22 PM