Repository: aio-libs-abandoned/aioredis-py

Issue:
calling close triggers deprecation warning in python 3.7
`DeprecationWarning: 'with await lock' is deprecated use 'async with lock' instead` in https://github.com/aio-libs/aioredis/blob/master/aioredis/pool.py#L146

Not sure if you officially support python 3.7 yet though.



Discussion:
Feel free to send a PR :)

Resolving patch:
diff --git a/aioredis/pool.py b/aioredis/pool.py
--- a/aioredis/pool.py
+++ b/aioredis/pool.py
@@ -130,7 +130,7 @@ async def clear(self):
 
         Close and remove all free connections.
         """
-        with (await self._cond):
+        async with self._cond:
             await self._do_clear()
 
     async def _do_clear(self):
@@ -143,7 +143,7 @@ async def _do_clear(self):
 
     async def _do_close(self):
         await self._close_state.wait()
-        with (await self._cond):
+        async with self._cond:
             assert not self._acquiring, self._acquiring
             waiters = []
             while self._pool:
@@ -269,7 +269,7 @@ async def _wait_execute_pubsub(self, address, command, args, kw):
             raise PoolClosedError("Pool is closed")
         assert self._pubsub_conn is None or self._pubsub_conn.closed, (
             "Expected no or closed connection", self._pubsub_conn)
-        with (await self._cond):
+        async with self._cond:
             if self.closed:
                 raise PoolClosedError("Pool is closed")
             if self._pubsub_conn is None or self._pubsub_conn.closed:
@@ -284,7 +284,7 @@ async def select(self, db):
         All previously acquired connections will be closed when released.
         """
         res = True
-        with (await self._cond):
+        async with self._cond:
             for i in range(self.freesize):
                 res = res and (await self._pool[i].select(db))
             else:
@@ -293,7 +293,7 @@ async def select(self, db):
 
     async def auth(self, password):
         self._password = password
-        with (await self._cond):
+        async with self._cond:
             for i in range(self.freesize):
                 await self._pool[i].auth(password)
 
@@ -322,7 +322,7 @@ async def acquire(self, command=None, args=()):
         """
         if self.closed:
             raise PoolClosedError("Pool is closed")
-        with await self._cond:
+        async with self._cond:
             if self.closed:
                 raise PoolClosedError("Pool is closed")
             while True:
@@ -419,7 +419,7 @@ def _create_new_connection(self, address):
                                  loop=self._loop)
 
     async def _wakeup(self, closing_conn=None):
-        with (await self._cond):
+        async with self._cond:
             self._cond.notify()
         if closing_conn is not None:
             await closing_conn.wait_closed()
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -40,6 +40,7 @@ def read_version():
     'Programming Language :: Python :: 3',
     'Programming Language :: Python :: 3.5',
     'Programming Language :: Python :: 3.6',
+    'Programming Language :: Python :: 3.7',
     'Programming Language :: Python :: 3 :: Only',
     'Operating System :: POSIX',
     'Environment :: Web Environment',


Test patch:
diff --git a/tests/pool_test.py b/tests/pool_test.py
--- a/tests/pool_test.py
+++ b/tests/pool_test.py
@@ -538,7 +538,7 @@ async def test_await(create_pool, server, loop):
         server.tcp_address,
         minsize=10, loop=loop)
 
-    with await pool as conn:
+    with (await pool) as conn:
         msg = await conn.execute('echo', 'hello')
         assert msg == b'hello'