Following on from reporting the bug, I have done more digging into the problem.

It seems to be related to styleQML lines when I check what connections are 
being sent to PostGIS. These don't disappear with each loop iteration in 
Master, but they do in version 2.0. Eventually when my script gets to 100 
connections, it hangs.

What can I do to make this work?

I have updated the bug report with more details, which can be found here 
https://hub.qgis.org/issues/9357.

James

Fra: qgis-developer-boun...@lists.osgeo.org 
[mailto:qgis-developer-boun...@lists.osgeo.org] På vegne av Stott James
Sendt: 16. januar 2014 14:23
Til: Tim Sutton
Kopi: qgis-developer@lists.osgeo.org
Emne: Re: [Qgis-developer] Issue with standalone python script and PostGIS 
Layers

Thanks for the response Tim.

I have not been destroying my layers. This has not been an issue when running 
the plugin with 2.0.

This was the first thing I thought about in the version running against master 
so I added the following code to close the postgis layers as it once I am 
finished with them:

QgsMapLayerRegistry.instance().removeMapLayer(layer_id)
This has not made it difference. It still hangs at the same place and I still 
get the warning that there is already too many clients when trying to connect 
to PostGIS with DB Manager or pgAdmin.

Shall I open a bug?

Fra: Tim Sutton [mailto:li...@linfiniti.com]
Sendt: 16. januar 2014 13:30
Til: Stott James
Kopi: qgis-developer@lists.osgeo.org<mailto:qgis-developer@lists.osgeo.org>
Emne: Re: [Qgis-developer] Issue with standalone python script and PostGIS 
Layers

Hi

On Thu, Jan 16, 2014 at 11:06 AM, Stott James 
<fmro...@fylkesmannen.no<mailto:fmro...@fylkesmannen.no>> wrote:
Hello all,

I have a standalone python script that creates a bunch of PDFs for me.

Recently this script has developed an issue. It uses QGIS-dev so it could be 
related to some of the changes in master recently as it works fine with QGIS 
2.0.

It makes about 42 PDFs then it stops.

It is not actually crashing as such, as you can see it running in task manager. 
It stays running using between 0 and 2% processor, and fluctuates a little with 
memory use (around 108840kB). But it does not produce any more PDFs. It is like 
it is stuck.

>From the log file that my script creates, I know that it is hanging with this 
>line of code:

vlayer = QgsVectorLayer(uri.uri(), layerName, "postgres")

If I try and connect to the database using DB Manager in QGIS or pgAdmin III 
while the script is still running, I get an error saying there is already too 
many clients already. If I kill the process in windows task manager, I am then 
able to connect to the database using DB manager.

Has anyone any suggestions as to what is wrong here? Is this a bug?

I updated QGIS dev this morning using the OSGeo4W installer (its revision is 
eb9ce3a).


If you are creating postgis layers in a loop, are you making sure to destroy 
them again nicely in your loop? Anyway if it used to work before maybe there 
was a regression somewhere....

Regards

Tim

James Stott

GIS-koordinator
Administrasjonsavdelinga
Fylkesmannen i Rogaland

Telefon: 51568793
james.st...@fylkesmannen.no<mailto:james.st...@fylkesmannen.no>
http://www.temakart-rogaland.no


_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org<mailto:Qgis-developer@lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/qgis-developer



--
Tim Sutton - QGIS Project Steering Committee Member
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Irc: timlinux on #qgis at freenode.net<http://freenode.net>
==============================================
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to