Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 8, 2018
1 parent 58da975 commit bbffad6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/src/python/providertestbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,3 +846,25 @@ def testStringComparison(self):
self.assertEqual(count, 5)
self.assertFalse(iterator.compileFailed())
self.disableCompiler()

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.
"""
# Acquire the maximum amount of concurrent connections
iterators = list()
for i in range(QgsApplication.instance().maxConcurrentConnectionsPerPool()):
iterators.append(self.vl.getFeatures())

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

feat = next(iterators[0])
context = QgsExpressionContext()
context.setFeature(feat)
exp = QgsExpression('get_feature(\'{layer}\', \'pk\', 5)'.format(layer=self.vl.id()))
exp.evaluate(context)

0 comments on commit bbffad6

Please sign in to comment.