<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 18 Apr 2023, 6:34 pm Radim Blazek via QGIS-Developer, <<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
with Qgis 3.28.3 called from Python, whenever QgsProject::clear() is<br>
called it creates new styles.db file, previous styles file is deleted<br>
from system, but it remains open (listed by lsof). It becomes a<br>
problem in server environment where every call to QgsProject::clear()<br>
creates a new file and limit of open files is soon reached.<br>
<br>
Just reading the code I was not able to trace down where / which<br>
object remains referenced. Maybe QgsStyle.mCurrentDB should be closed<br>
explicitly?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It will only get freed when the event loop is next executed. </div><div dir="auto"><br></div><div dir="auto">You can safely execute the event loop with DeferredDelete to only cleanup of this object without the danger of other event loop mess.</div><div dir="auto"><br></div><div dir="auto">Nyall</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Is it OK to use this workaround?:<br>
project = QgsProject(None, Qgis.ProjectCapabilities())<br>
QgsProject.setInstance(project)<br>
<br>
BTW, how can I modify QgsProject.capabilities() from Python?<br>
<br>
Radim<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank" rel="noreferrer">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer 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 noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div></div></div>