Close the connection reset watching state and raise an exception if we were watching. The supported exceptions are already checked in the retry object so we don't need to do it here. After we disconnect the connection, it will try to reconnect and d
(
self,
conn: AbstractConnection,
error: Exception,
failure_count: Optional[int] = None,
start_time: Optional[float] = None,
command_name: Optional[str] = None,
)
| 1766 | return self.pipeline_execute_command(*args, **kwargs) |
| 1767 | |
| 1768 | def _disconnect_reset_raise_on_watching( |
| 1769 | self, |
| 1770 | conn: AbstractConnection, |
| 1771 | error: Exception, |
| 1772 | failure_count: Optional[int] = None, |
| 1773 | start_time: Optional[float] = None, |
| 1774 | command_name: Optional[str] = None, |
| 1775 | ) -> None: |
| 1776 | """ |
| 1777 | Close the connection reset watching state and |
| 1778 | raise an exception if we were watching. |
| 1779 | |
| 1780 | The supported exceptions are already checked in the |
| 1781 | retry object so we don't need to do it here. |
| 1782 | |
| 1783 | After we disconnect the connection, it will try to reconnect and |
| 1784 | do a health check as part of the send_command logic(on connection level). |
| 1785 | """ |
| 1786 | if error and failure_count <= conn.retry.get_retries(): |
| 1787 | record_operation_duration( |
| 1788 | command_name=command_name, |
| 1789 | duration_seconds=time.monotonic() - start_time, |
| 1790 | server_address=getattr(conn, "host", None), |
| 1791 | server_port=getattr(conn, "port", None), |
| 1792 | db_namespace=str(conn.db), |
| 1793 | error=error, |
| 1794 | retry_attempts=failure_count, |
| 1795 | ) |
| 1796 | conn.disconnect() |
| 1797 | |
| 1798 | # if we were already watching a variable, the watch is no longer |
| 1799 | # valid since this connection has died. raise a WatchError, which |
| 1800 | # indicates the user should retry this transaction. |
| 1801 | if self.watching: |
| 1802 | self.reset() |
| 1803 | raise WatchError( |
| 1804 | f"A {type(error).__name__} occurred while watching one or more keys" |
| 1805 | ) |
| 1806 | |
| 1807 | def immediate_execute_command(self, *args, **options): |
| 1808 | """ |
no test coverage detected