Check if the response is a health check response. If there are no subscriptions redis responds to PING command with a bulk response, instead of a multi-bulk with "pong" and the response.
(self, response)
| 1273 | return response |
| 1274 | |
| 1275 | def is_health_check_response(self, response) -> bool: |
| 1276 | """ |
| 1277 | Check if the response is a health check response. |
| 1278 | If there are no subscriptions redis responds to PING command with a |
| 1279 | bulk response, instead of a multi-bulk with "pong" and the response. |
| 1280 | """ |
| 1281 | if self.encoder.decode_responses: |
| 1282 | return ( |
| 1283 | response |
| 1284 | in [ |
| 1285 | self.health_check_response, # If there is a subscription |
| 1286 | self.HEALTH_CHECK_MESSAGE, # If there are no subscriptions and decode_responses=True |
| 1287 | ] |
| 1288 | ) |
| 1289 | else: |
| 1290 | return ( |
| 1291 | response |
| 1292 | in [ |
| 1293 | self.health_check_response, # If there is a subscription |
| 1294 | self.health_check_response_b, # If there isn't a subscription and decode_responses=False |
| 1295 | ] |
| 1296 | ) |
| 1297 | |
| 1298 | def check_health(self) -> None: |
| 1299 | conn = self.connection |
no outgoing calls