Skip to content

Commit bbffad6

Browse files
committed
Fix test
1 parent 58da975 commit bbffad6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/src/python/providertestbase.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,25 @@ def testStringComparison(self):
846846
self.assertEqual(count, 5)
847847
self.assertFalse(iterator.compileFailed())
848848
self.disableCompiler()
849+
850+
def testConcurrency(self):
851+
"""
852+
The connection pool has a maximum of 4 connections defined (+2 spare connections)
853+
Make sure that if we exhaust those 4 connections and force another connection
854+
it is actually using the spare connections and does not freeze.
855+
This situation normally happens when (at least) 4 rendering threads are active
856+
in parallel and one requires an expression to be evaluated.
857+
"""
858+
# Acquire the maximum amount of concurrent connections
859+
iterators = list()
860+
for i in range(QgsApplication.instance().maxConcurrentConnectionsPerPool()):
861+
iterators.append(self.vl.getFeatures())
862+
863+
# Run an expression that will also do a request and should use a spare
864+
# connection. It just should not deadlock here.
865+
866+
feat = next(iterators[0])
867+
context = QgsExpressionContext()
868+
context.setFeature(feat)
869+
exp = QgsExpression('get_feature(\'{layer}\', \'pk\', 5)'.format(layer=self.vl.id()))
870+
exp.evaluate(context)

0 commit comments

Comments
 (0)