File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -846,3 +846,25 @@ def testStringComparison(self):
846
846
self .assertEqual (count , 5 )
847
847
self .assertFalse (iterator .compileFailed ())
848
848
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 )
You can’t perform that action at this time.
0 commit comments