Execute a command immediately, but don't auto-retry on the supported errors for retry if we're already WATCHing a variable. Used when issuing WATCH or subsequent commands retrieving their values but before MULTI is called.
(self, *args, **options)
| 1805 | ) |
| 1806 | |
| 1807 | def immediate_execute_command(self, *args, **options): |
| 1808 | """ |
| 1809 | Execute a command immediately, but don't auto-retry on the supported |
| 1810 | errors for retry if we're already WATCHing a variable. |
| 1811 | Used when issuing WATCH or subsequent commands retrieving their values but before |
| 1812 | MULTI is called. |
| 1813 | """ |
| 1814 | command_name = args[0] |
| 1815 | conn = self.connection |
| 1816 | # if this is the first call, we need a connection |
| 1817 | if not conn: |
| 1818 | conn = self.connection_pool.get_connection() |
| 1819 | self.connection = conn |
| 1820 | |
| 1821 | # Start timing for observability |
| 1822 | start_time = time.monotonic() |
| 1823 | # Track actual retry attempts for error reporting |
| 1824 | actual_retry_attempts = [0] |
| 1825 | |
| 1826 | def failure_callback(error, failure_count): |
| 1827 | if is_debug_log_enabled(): |
| 1828 | add_debug_log_for_operation_failure(conn) |
| 1829 | actual_retry_attempts[0] = failure_count |
| 1830 | self._disconnect_reset_raise_on_watching( |
| 1831 | conn, error, failure_count, start_time, command_name |
| 1832 | ) |
| 1833 | |
| 1834 | try: |
| 1835 | response = conn.retry.call_with_retry( |
| 1836 | lambda: self._send_command_parse_response( |
| 1837 | conn, command_name, *args, **options |
| 1838 | ), |
| 1839 | failure_callback, |
| 1840 | with_failure_count=True, |
| 1841 | ) |
| 1842 | |
| 1843 | record_operation_duration( |
| 1844 | command_name=command_name, |
| 1845 | duration_seconds=time.monotonic() - start_time, |
| 1846 | server_address=getattr(conn, "host", None), |
| 1847 | server_port=getattr(conn, "port", None), |
| 1848 | db_namespace=str(conn.db), |
| 1849 | ) |
| 1850 | |
| 1851 | return response |
| 1852 | except Exception as e: |
| 1853 | record_error_count( |
| 1854 | server_address=getattr(conn, "host", None), |
| 1855 | server_port=getattr(conn, "port", None), |
| 1856 | network_peer_address=getattr(conn, "host", None), |
| 1857 | network_peer_port=getattr(conn, "port", None), |
| 1858 | error_type=e, |
| 1859 | retry_attempts=actual_retry_attempts[0], |
| 1860 | is_internal=False, |
| 1861 | ) |
| 1862 | raise |
| 1863 | |
| 1864 | def pipeline_execute_command(self, *args, **options) -> "Pipeline": |