| 1430 | eq_(canary, [1, 1, 2, 2, 2, 2, 2]) |
| 1431 | |
| 1432 | def test_dispose_closes_pooled(self): |
| 1433 | dbapi = MockDBAPI() |
| 1434 | |
| 1435 | p = pool.QueuePool( |
| 1436 | creator=dbapi.connect, pool_size=2, timeout=None, max_overflow=0 |
| 1437 | ) |
| 1438 | c1 = p.connect() |
| 1439 | c2 = p.connect() |
| 1440 | c1_con = c1.dbapi_connection |
| 1441 | c2_con = c2.dbapi_connection |
| 1442 | |
| 1443 | c1.close() |
| 1444 | |
| 1445 | eq_(c1_con.close.call_count, 0) |
| 1446 | eq_(c2_con.close.call_count, 0) |
| 1447 | |
| 1448 | p.dispose() |
| 1449 | |
| 1450 | eq_(c1_con.close.call_count, 1) |
| 1451 | eq_(c2_con.close.call_count, 0) |
| 1452 | |
| 1453 | # currently, if a ConnectionFairy is closed |
| 1454 | # after the pool has been disposed, there's no |
| 1455 | # flag that states it should be invalidated |
| 1456 | # immediately - it just gets returned to the |
| 1457 | # pool normally... |
| 1458 | c2.close() |
| 1459 | eq_(c1_con.close.call_count, 1) |
| 1460 | eq_(c2_con.close.call_count, 0) |
| 1461 | |
| 1462 | # ...and that's the one we'll get back next. |
| 1463 | c3 = p.connect() |
| 1464 | assert c3.dbapi_connection is c2_con |
| 1465 | |
| 1466 | @testing.requires.threading_with_mock |
| 1467 | @testing.requires.timing_intensive |