mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Add test for nested connection pool acquire freeze
This commit is contained in:
parent
62a56b195c
commit
7033b54483
@ -44,7 +44,9 @@ from qgis.core import (
|
||||
QgsCoordinateReferenceSystem,
|
||||
QgsProject,
|
||||
QgsWkbTypes,
|
||||
QgsGeometry
|
||||
QgsGeometry,
|
||||
QgsExpression,
|
||||
QgsExpressionContext
|
||||
)
|
||||
from qgis.gui import QgsGui, QgsAttributeForm
|
||||
from qgis.PyQt.QtCore import QDate, QTime, QDateTime, QVariant, QDir, QObject
|
||||
@ -1141,6 +1143,27 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
|
||||
self.assertEqual(g.childCount(), 1)
|
||||
self.assertTrue(g.childGeometry(0).vertexCount() > 3)
|
||||
|
||||
def testConcurrency(self):
|
||||
"""
|
||||
The connection pool has a maximum of 4 connections defined (+2 spare connections)
|
||||
Make sure that if we exhaust those 4 connections and force another connection
|
||||
it is actually using the spare connections and does not freeze.
|
||||
This situation normally happens when (at least) 4 rendering threads are active
|
||||
in parallel and one requires an expression to be evaluated.
|
||||
"""
|
||||
vl = QgsVectorLayer('{conn} srid=4326 table="qgis_test".{table} (geom) sql='.format(conn=self.dbconn, table='someData'), "testgeom", "postgres")
|
||||
self.assertTrue(vl.isValid())
|
||||
it = vl.getFeatures()
|
||||
it2 = vl.getFeatures()
|
||||
it3 = vl.getFeatures()
|
||||
it4 = vl.getFeatures()
|
||||
QgsProject.instance().addMapLayer(vl)
|
||||
feat = next(it)
|
||||
context = QgsExpressionContext()
|
||||
context.setFeature(feat)
|
||||
exp = QgsExpression('get_feature(\'{layer}\', \'pk\', 5)'.format(layer=vl.id()))
|
||||
exp.evaluate(context)
|
||||
|
||||
|
||||
class TestPyQgsPostgresProviderCompoundKey(unittest.TestCase, ProviderTestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user