@@ -94,14 +94,14 @@ def parse_debug_object(response):
94
94
95
95
96
96
def parse_object (response , infotype ):
97
- "Parse the results of an OBJECT command"
97
+ """ Parse the results of an OBJECT command"" "
98
98
if infotype in ("idletime" , "refcount" ):
99
99
return int_or_none (response )
100
100
return response
101
101
102
102
103
103
def parse_info (response ):
104
- "Parse the result of Redis's INFO command into a Python dict"
104
+ """ Parse the result of Redis's INFO command into a Python dict"" "
105
105
info = {}
106
106
response = str_if_bytes (response )
107
107
@@ -145,7 +145,7 @@ def get_value(value):
145
145
146
146
147
147
def parse_memory_stats (response , ** kwargs ):
148
- "Parse the results of MEMORY STATS"
148
+ """ Parse the results of MEMORY STATS"" "
149
149
stats = pairs_to_dict (response , decode_keys = True , decode_string_values = True )
150
150
for key , value in stats .items ():
151
151
if key .startswith ("db." ):
@@ -219,7 +219,7 @@ def parse_sentinel_get_master(response):
219
219
220
220
221
221
def pairs_to_dict (response , decode_keys = False , decode_string_values = False ):
222
- "Create a dict given a list of key/value pairs"
222
+ """ Create a dict given a list of key/value pairs"" "
223
223
if response is None :
224
224
return {}
225
225
if decode_keys or decode_string_values :
@@ -973,19 +973,15 @@ def __repr__(self):
973
973
return f"{ type (self ).__name__ } <{ repr (self .connection_pool )} >"
974
974
975
975
def get_encoder (self ):
976
- """
977
- Get the connection pool's encoder
978
- """
976
+ """Get the connection pool's encoder"""
979
977
return self .connection_pool .get_encoder ()
980
978
981
979
def get_connection_kwargs (self ):
982
- """
983
- Get the connection's key-word arguments
984
- """
980
+ """Get the connection's key-word arguments"""
985
981
return self .connection_pool .connection_kwargs
986
982
987
983
def set_response_callback (self , command , callback ):
988
- "Set a custom Response Callback"
984
+ """ Set a custom Response Callback"" "
989
985
self .response_callbacks [command ] = callback
990
986
991
987
def load_external_module (
@@ -1165,7 +1161,7 @@ def _disconnect_raise(self, conn, error):
1165
1161
1166
1162
# COMMAND EXECUTION AND PROTOCOL PARSING
1167
1163
def execute_command (self , * args , ** options ):
1168
- "Execute a command and return a parsed response"
1164
+ """ Execute a command and return a parsed response"" "
1169
1165
pool = self .connection_pool
1170
1166
command_name = args [0 ]
1171
1167
conn = self .connection or pool .get_connection (command_name , ** options )
@@ -1182,7 +1178,7 @@ def execute_command(self, *args, **options):
1182
1178
pool .release (conn )
1183
1179
1184
1180
def parse_response (self , connection , command_name , ** options ):
1185
- "Parses a response from the Redis server"
1181
+ """ Parses a response from the Redis server"" "
1186
1182
try :
1187
1183
if NEVER_DECODE in options :
1188
1184
response = connection .read_response (disable_decoding = True )
@@ -1227,7 +1223,7 @@ def __exit__(self, *args):
1227
1223
self .connection_pool .release (self .connection )
1228
1224
1229
1225
def next_command (self ):
1230
- "Parse the response from a monitor command"
1226
+ """ Parse the response from a monitor command"" "
1231
1227
response = self .connection .read_response ()
1232
1228
if isinstance (response , bytes ):
1233
1229
response = self .connection .encoder .decode (response , force = True )
@@ -1262,7 +1258,7 @@ def next_command(self):
1262
1258
}
1263
1259
1264
1260
def listen (self ):
1265
- "Listen for commands coming to the server."
1261
+ """ Listen for commands coming to the server."" "
1266
1262
while True :
1267
1263
yield self .next_command ()
1268
1264
@@ -1355,11 +1351,11 @@ def on_connect(self, connection):
1355
1351
1356
1352
@property
1357
1353
def subscribed (self ):
1358
- "Indicates if there are subscriptions to any channels or patterns"
1354
+ """ Indicates if there are subscriptions to any channels or patterns"" "
1359
1355
return self .subscribed_event .is_set ()
1360
1356
1361
1357
def execute_command (self , * args ):
1362
- "Execute a publish/subscribe command"
1358
+ """ Execute a publish/subscribe command"" "
1363
1359
1364
1360
# NOTE: don't parse the response in this function -- it could pull a
1365
1361
# legitimate message off the stack if the connection is already
@@ -1751,7 +1747,7 @@ def __len__(self):
1751
1747
return len (self .command_stack )
1752
1748
1753
1749
def __bool__ (self ):
1754
- "Pipeline instances should always evaluate to True"
1750
+ """ Pipeline instances should always evaluate to True"" "
1755
1751
return True
1756
1752
1757
1753
def reset (self ):
@@ -1992,7 +1988,7 @@ def _disconnect_raise_reset(self, conn, error):
1992
1988
raise
1993
1989
1994
1990
def execute (self , raise_on_error = True ):
1995
- "Execute all the commands in the current pipeline"
1991
+ """ Execute all the commands in the current pipeline"" "
1996
1992
stack = self .command_stack
1997
1993
if not stack and not self .watching :
1998
1994
return []
@@ -2019,17 +2015,18 @@ def execute(self, raise_on_error=True):
2019
2015
self .reset ()
2020
2016
2021
2017
def discard (self ):
2022
- """Flushes all previously queued commands
2018
+ """
2019
+ Flushes all previously queued commands
2023
2020
See: https://redis.io/commands/DISCARD
2024
2021
"""
2025
2022
self .execute_command ("DISCARD" )
2026
2023
2027
2024
def watch (self , * names ):
2028
- "Watches the values at keys ``names``"
2025
+ """ Watches the values at keys ``names``"" "
2029
2026
if self .explicit_transaction :
2030
2027
raise RedisError ("Cannot issue a WATCH after a MULTI" )
2031
2028
return self .execute_command ("WATCH" , * names )
2032
2029
2033
2030
def unwatch (self ):
2034
- "Unwatches all previously specified keys"
2031
+ """ Unwatches all previously specified keys"" "
2035
2032
return self .watching and self .execute_command ("UNWATCH" ) or True
0 commit comments