8000 Fall back to asyncio.async when asyncio.ensure_future is not available. · chdsbd/asyncio-redis@68687da · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 68687da

Browse files
Fall back to asyncio.async when asyncio.ensure_future is not available.
1 parent a5ab167 commit 68687da

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

asyncio_redis/connection.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
__all__ = ('Connection', )
88

99

10+
# In Python 3.4.4, `async` was renamed to `ensure_future`.
11+
try:
12+
ensure_future = asyncio.ensure_future
13+
except AttributeError:
14+
ensure_future = asyncio.async
15+
16+
1017
class Connection:
1118
"""
1219
Wrapper around the protocol and transport which takes care of establishing
@@ -54,7 +61,7 @@ def create(cls, host='localhost', port=6379, *, password=None, db=0,
5461
# Create protocol instance
5562
def connection_lost():
5663
if connection._auto_reconnect and not connection._closing:
57-
asyncio.ensure_future(connection._reconnect(), loop=connection._loop)
64+
ensure_future(connection._reconnect(), loop=connection._loop)
5865

5966
# Create protocol instance
6067
connection.protocol = protocol_class(password=password, db=db, encoder=encoder,

0 commit comments

Comments
 (0)
0