MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_notify_waiters

Method test_notify_waiters

test/engine/test_pool.py:1396–1432  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1394 @testing.requires.threading_with_mock
1395 @testing.requires.timing_intensive
1396 def test_notify_waiters(self):
1397 dbapi = MockDBAPI()
1398
1399 canary = []
1400
1401 def creator():
1402 canary.append(1)
1403 return dbapi.connect()
1404
1405 p1 = pool.QueuePool(
1406 creator=creator, pool_size=1, timeout=None, max_overflow=0
1407 )
1408
1409 def waiter(p):
1410 conn = p.connect()
1411 canary.append(2)
1412 time.sleep(0.5)
1413 conn.close()
1414
1415 c1 = p1.connect()
1416
1417 threads = []
1418 for i in range(5):
1419 t = threading.Thread(target=waiter, args=(p1,))
1420 t.start()
1421 threads.append(t)
1422 time.sleep(0.5)
1423 eq_(canary, [1])
1424
1425 # this also calls invalidate()
1426 # on c1
1427 p1._invalidate(c1)
1428
1429 for t in threads:
1430 t.join(join_timeout)
1431
1432 eq_(canary, [1, 1, 2, 2, 2, 2, 2])
1433
1434 def test_dispose_closes_pooled(self):
1435 dbapi = MockDBAPI()

Callers

nothing calls this directly

Calls 7

eq_Function · 0.90
_invalidateMethod · 0.80
MockDBAPIFunction · 0.70
connectMethod · 0.45
startMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected