Skip to content

Commit ace173a

Browse files
committed
remove deprecated Pool.get
1 parent eb7250f commit ace173a

File tree

8 files changed

+22
-38
lines changed

8 files changed

+22
-38
lines changed

CHANGES.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ Changes
22
-------
33

44
next (unreleased)
5-
^^^^^^^^^^^^^^^^^^
5+
^^^^^^^^^^^^^^^^^
66

77
* Bump minimal SQLAlchemy version to 1.3 #815
88

9+
* Remove deprecated Pool.get #706
10+
911
0.1.1 (2022-05-08)
1012
^^^^^^^^^^^^^^^^^^
1113

aiomysql/pool.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,6 @@ def release(self, conn):
230230
fut = self._loop.create_task(self._wakeup())
231231
return fut
232232

233-
def get(self):
234-
warnings.warn("pool.get deprecated use pool.acquire instead",
235-
DeprecationWarning,
236-
stacklevel=2)
237-
return _PoolConnectionContextManager(self, None)
238-
239233
def __enter__(self):
240234
raise RuntimeError(
241235
'"yield from" should be used as context manager expression')

examples/example_ssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async def main():
1313
password='rootpw', ssl=ctx,
1414
auth_plugin='mysql_clear_password') as pool:
1515

16-
async with pool.get() as conn:
16+
async with pool.acquire() as conn:
1717
async with conn.cursor() as cur:
1818
# Run simple command
1919
await cur.execute("SHOW DATABASES;")

tests/test_async_with.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,6 @@ async def test_pool(table, pool_creator, loop):
126126

127127
@pytest.mark.run_loop
128128
async def test_create_pool_deprecations(mysql_params, loop):
129-
async with create_pool(loop=loop, **mysql_params) as pool:
130-
with warnings.catch_warnings(record=True) as w:
131-
warnings.simplefilter("always")
132-
async with pool.get() as conn:
133-
pass
134-
# The first warning emitted is expected to be DeprecationWarning:
135-
# in the past, we used to check for the last one but this assumption
136-
# breaks under Python 3.7 that also emits a `ResourceWarning` when
137-
# executed with `PYTHONASYNCIODEBUG=1`.
138-
assert issubclass(w[0].category, DeprecationWarning)
139-
assert conn.closed
140-
141129
async with create_pool(loop=loop, **mysql_params) as pool:
142130
with warnings.catch_warnings(record=True) as w:
143131
warnings.simplefilter("always")

tests/test_issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ async def test_issue_175(connection):
427427
async def test_issue_323(mysql_server, loop, recwarn):
428428
async with aiomysql.create_pool(**mysql_server['conn_params'],
429429
loop=loop) as pool:
430-
async with pool.get() as conn:
430+
async with pool.acquire() as conn:
431431
async with conn.cursor() as cur:
432432
drop_db = "DROP DATABASE IF EXISTS bugtest;"
433433
await cur.execute(drop_db)

tests/test_pool.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async def test_bad_context_manager_usage(pool_creator):
7979
@pytest.mark.run_loop
8080
async def test_context_manager(pool_creator):
8181
pool = await pool_creator(minsize=10, maxsize=10)
82-
async with pool.get() as conn:
82+
async with pool.acquire() as conn:
8383
assert isinstance(conn, Connection)
8484
assert 9 == pool.freesize
8585
assert {conn} == pool._used
@@ -101,7 +101,7 @@ async def test_initial_empty(pool_creator):
101101
assert 0 == pool.size
102102
assert 0 == pool.freesize
103103

104-
async with pool.get():
104+
async with pool.acquire():
105105
assert 1 == pool.size
106106
assert 0 == pool.freesize
107107
assert 1 == pool.size
@@ -236,7 +236,7 @@ async def test_release_with_invalid_status_wait_release(pool_creator):
236236
@pytest.mark.run_loop
237237
async def test__fill_free(pool_creator, loop):
238238
pool = await pool_creator(minsize=1)
239-
async with pool.get():
239+
async with pool.acquire():
240240
assert 0 == pool.freesize
241241
assert 1 == pool.size
242242

@@ -256,7 +256,7 @@ async def test_connect_from_acquire(pool_creator):
256256
pool = await pool_creator(minsize=0)
257257
assert 0 == pool.freesize
258258
assert 0 == pool.size
259-
async with pool.get():
259+
async with pool.acquire():
260260
assert 1 == pool.size
261261
assert 0 == pool.freesize
262262
assert 1 == pool.size
@@ -353,7 +353,7 @@ async def test_echo(pool_creator):
353353
pool = await pool_creator(echo=True)
354354
assert pool.echo
355355

356-
async with pool.get() as conn:
356+
async with pool.acquire() as conn:
357357
assert conn.echo
358358

359359

@@ -482,7 +482,7 @@ async def test_cancelled_connection(pool_creator, loop):
482482
pool = await pool_creator(minsize=0, maxsize=1)
483483

484484
try:
485-
async with pool.get() as conn:
485+
async with pool.acquire() as conn:
486486
curs = await conn.cursor()
487487
# Cancel a cursor in the middle of execution, before it
488488
# could read even the first packet (SLEEP assures the
@@ -495,7 +495,7 @@ async def test_cancelled_connection(pool_creator, loop):
495495
except asyncio.CancelledError:
496496
pass
497497

498-
async with pool.get() as conn:
498+
async with pool.acquire() as conn:
499499
cur2 = await conn.cursor()
500500
res = await cur2.execute("SELECT 2 as value, 0 as xxx")
501501
names = [x[0] for x in cur2.description]
@@ -509,7 +509,7 @@ async def test_cancelled_connection(pool_creator, loop):
509509
@pytest.mark.run_loop
510510
async def test_pool_with_connection_recycling(pool_creator, loop):
511511
pool = await pool_creator(minsize=1, maxsize=1, pool_recycle=3)
512-
async with pool.get() as conn:
512+
async with pool.acquire() as conn:
513513
cur = await conn.cursor()
514514
await cur.execute('SELECT 1;')
515515
val = await cur.fetchone()
@@ -518,7 +518,7 @@ async def test_pool_with_connection_recycling(pool_creator, loop):
518518
await asyncio.sleep(5)
519519

520520
assert 1 == pool.freesize
521-
async with pool.get() as conn:
521+
async with pool.acquire() as conn:
522522
cur = await conn.cursor()
523523
await cur.execute('SELECT 1;')
524524
val = await cur.fetchone()
@@ -529,14 +529,14 @@ async def test_pool_with_connection_recycling(pool_creator, loop):
529529
async def test_pool_drops_connection_with_exception(pool_creator, loop):
530530
pool = await pool_creator(minsize=1, maxsize=1)
531531

532-
async with pool.get() as conn:
532+
async with pool.acquire() as conn:
533533
cur = await conn.cursor()
534534
await cur.execute('SELECT 1;')
535535

536536
connection, = pool._free
537537
connection._writer._protocol.connection_lost(IOError())
538538

539-
async with pool.get() as conn:
539+
async with pool.acquire() as conn:
540540
cur = await conn.cursor()
541541
await cur.execute('SELECT 1;')
542542

tests/test_sha_connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def test_sha256_nopw(mysql_server, loop):
3939

4040
async with create_pool(**connection_data,
4141
loop=loop) as pool:
42-
async with pool.get() as conn:
42+
async with pool.acquire() as conn:
4343
# User doesnt have any permissions to look at DBs
4444
# But as 8.0 will default to caching_sha2_password
4545
assert conn._auth_plugin_used == 'sha256_password'
@@ -62,7 +62,7 @@ async def test_sha256_pw(mysql_server, loop):
6262

6363
async with create_pool(**connection_data,
6464
loop=loop) as pool:
65-
async with pool.get() as conn:
65+
async with pool.acquire() as conn:
6666
# User doesnt have any permissions to look at DBs
6767
# But as 8.0 will default to caching_sha2_password
6868
assert conn._auth_plugin_used == 'sha256_password'
@@ -78,7 +78,7 @@ async def test_cached_sha256_nopw(mysql_server, loop):
7878

7979
async with create_pool(**connection_data,
8080
loop=loop) as pool:
81-
async with pool.get() as conn:
81+
async with pool.acquire() as conn:
8282
# User doesnt have any permissions to look at DBs
8383
# But as 8.0 will default to caching_sha2_password
8484
assert conn._auth_plugin_used == 'caching_sha2_password'
@@ -94,7 +94,7 @@ async def test_cached_sha256_pw(mysql_server, loop):
9494

9595
async with create_pool(**connection_data,
9696
loop=loop) as pool:
97-
async with pool.get() as conn:
97+
async with pool.acquire() as conn:
9898
# User doesnt have any permissions to look at DBs
9999
# But as 8.0 will default to caching_sha2_password
100100
assert conn._auth_plugin_used == 'caching_sha2_password'

tests/test_ssl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async def test_tls_connect(mysql_server, loop, mysql_params):
1010

1111
async with create_pool(**mysql_server['conn_params'],
1212
loop=loop) as pool:
13-
async with pool.get() as conn:
13+
async with pool.acquire() as conn:
1414
async with conn.cursor() as cur:
1515
# Run simple command
1616
await cur.execute("SHOW DATABASES;")
@@ -42,7 +42,7 @@ async def test_auth_plugin_renegotiation(mysql_server, loop, mysql_params):
4242
async with create_pool(**mysql_server['conn_params'],
4343
auth_plugin='mysql_clear_password',
4444
loop=loop) as pool:
45-
async with pool.get() as conn:
45+
async with pool.acquire() as conn:
4646
async with conn.cursor() as cur:
4747
# Run simple command
4848
await cur.execute("SHOW DATABASES;")

0 commit comments

Comments
 (0)