Wrapper for RedisCluster.ERRORS_ALLOW_RETRY errors handling. If one of the retryable exceptions has been thrown we assume that: - connection_pool was disconnected - connection_pool was reset - refresh_table_asap set to True It will try the number
(
self, stack, raise_on_error=True, allow_redirections=True
)
| 4023 | self._command_queue = [] |
| 4024 | |
| 4025 | def send_cluster_commands( |
| 4026 | self, stack, raise_on_error=True, allow_redirections=True |
| 4027 | ): |
| 4028 | """ |
| 4029 | Wrapper for RedisCluster.ERRORS_ALLOW_RETRY errors handling. |
| 4030 | |
| 4031 | If one of the retryable exceptions has been thrown we assume that: |
| 4032 | - connection_pool was disconnected |
| 4033 | - connection_pool was reset |
| 4034 | - refresh_table_asap set to True |
| 4035 | |
| 4036 | It will try the number of times specified by |
| 4037 | the retries in config option "self.retry" |
| 4038 | which defaults to 10 unless manually configured. |
| 4039 | |
| 4040 | If it reaches the number of times, the command will |
| 4041 | raises ClusterDownException. |
| 4042 | """ |
| 4043 | if not stack: |
| 4044 | return [] |
| 4045 | retry_attempts = self._pipe.retry.get_retries() |
| 4046 | while True: |
| 4047 | try: |
| 4048 | return self._send_cluster_commands( |
| 4049 | stack, |
| 4050 | raise_on_error=raise_on_error, |
| 4051 | allow_redirections=allow_redirections, |
| 4052 | ) |
| 4053 | except RedisCluster.ERRORS_ALLOW_RETRY as e: |
| 4054 | if retry_attempts > 0: |
| 4055 | # Try again with the new cluster setup. All other errors |
| 4056 | # should be raised. |
| 4057 | retry_attempts -= 1 |
| 4058 | pass |
| 4059 | else: |
| 4060 | raise e |
| 4061 | |
| 4062 | def _send_cluster_commands( |
| 4063 | self, stack, raise_on_error=True, allow_redirections=True |
no test coverage detected