8000 Added missing @asyncio.coroutine · chdsbd/asyncio-redis@1c19f29 · 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 1c19f29

Browse files
Martiuswebjonathanslenders
authored andcommitted
Added missing @asyncio.coroutine
Python 3.5 introduces the couple of keywords async/await. They are compatible with the "yield from" syntax and generator coroutines as long as they are decorated with @asyncio.coroutine. Some of them where missing, so code like: async def coro(redis_client): await redis_client.watch(key) failed with the error: TypeError: object generator can't be used in 'await' expression
1 parent 31d03ae commit 1c19f29

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

asyncio_redis/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def _increase_retry_interval(self):
8282
""" When a connection failed. Increase the interval."""
8383
self._retry_interval = min(60, 1.5 * self._retry_interval)
8484

85+
@asyncio.coroutine
8586
def _reconnect(self):
8687
"""
8788
Set up Redis connection.

asyncio_redis/protocol.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ def _get_wrapped_method(self, post_process, suffix, return_type):
611611
# directly on the protocol, outside of transactions or from the
612612
# transaction object.
613613
@wraps(method)
614+
@asyncio.coroutine
614615
def wrapper(protocol_self, *a, **kw):
615616
# When calling from a transaction
616617
if protocol_self.in_transaction:
@@ -689,6 +690,7 @@ def get_methods(self):
689690
# List of all command methods.
690691
_all_commands = []
691692

693+
692694
class _command:
693695
""" Mark method as command (to be passed through CommandCreator for the
694696
creation of a protocol method) """
@@ -1981,6 +1983,7 @@ def client_kill(self, address:str) -> StatusReply:
19811983
# LUA scripting
19821984

19831985
@_command
1986+
@asyncio.coroutine
19841987
def register_script(self, script:str) -> 'Script':
19851988
"""
19861989
Register a LUA script.
@@ -2006,6 +2009,7 @@ def script_flush(self) -> StatusReply:
20062009
return self._query(b'script', b'flush')
20072010

20082011
@_query_command
2012+
@asyncio.coroutine
20092013
def script_kill(self) -> StatusReply:
20102014
"""
20112015
Kill the script currently in execution. This raises
@@ -2021,6 +2025,7 @@ def script_kill(self) -> StatusReply:
20212025
raise
20222026

20232027
@_query_command
2028+
@asyncio.coroutine
20242029
def evalsha(self, sha:str,
20252030
keys:(ListOf(NativeType), NoneType)=None,
20262031
args:(ListOf(NativeType), NoneType)=None) -> EvalScriptReply:

0 commit comments

Comments
 (0)
0