Skip to content

Commit a615f9a

Browse files
committed
Add failing test that reproduces bad connection.
1 parent 67b01a8 commit a615f9a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

tests/test_pool.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ async def test_cancelled_connection(pool_creator, loop):
492492
# If we receive [(1, 0)] - we retrieved old cursor's values
493493
assert list(res) == [(2, 0)]
494494

495-
495+
@pytest.mark.run_loop
496496
async def test_pool_with_connection_recycling(pool_creator, loop):
497497
pool = await pool_creator(minsize=1, maxsize=1, pool_recycle=3)
498498
async with pool.get() as conn:
@@ -509,3 +509,18 @@ async def test_pool_with_connection_recycling(pool_creator, loop):
509509
await cur.execute('SELECT 1;')
510510
val = await cur.fetchone()
511511
assert (1,) == val
512+
513+
@pytest.mark.run_loop
514+
async def test_pool_does_not_reuse_connection_with_exception(pool_creator, loop):
515+
pool = await pool_creator(minsize=1, maxsize=1)
516+
517+
async with pool.get() as conn:
518+
cur = await conn.cursor()
519+
await cur.execute('SELECT 1;')
520+
521+
connection, = pool._free
522+
connection._reader.set_exception(IOError())
523+
524+
async with pool.get() as conn:
525+
cur = await conn.cursor()
526+
await cur.execute('SELECT 1;')

0 commit comments

Comments
 (0)