Skip to content
Browse files
Make nested iterator request test solid for max conn count changes
  • Loading branch information
m-kuhn committed Aug 8, 2018
1 parent 955323f commit ec4a327502c88554a704f28ecf6a97b676e9fa37
Showing with 26 additions and 0 deletions.
  1. +26 −0 tests/src/python/
@@ -1141,6 +1141,32 @@ def testCurveToMultipolygon(self):
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")

# Acquire the maximum amount of concurrent connections
iterators = list()
for i in range(QgsApplication.instance().maxConcurrentConnectionsPerPool()):

# Run an expression that will also do a request and should use a spare
# connection. It just should not deadlock here.

feat = next(it)
context = QgsExpressionContext()
exp = QgsExpression('get_feature(\'{layer}\', \'pk\', 5)'.format(

class TestPyQgsPostgresProviderCompoundKey(unittest.TestCase, ProviderTestCase):

0 comments on commit ec4a327

Please sign in to comment.