redis/redis-py · error · NotImplementedError

LATENCY DOCTOR is intentionally not implemented in the…

Error message

LATENCY DOCTOR is intentionally not implemented in the client. For more information, see https://redis.io/commands/latency-doctor

What it means

Raised by latency_doctor() (redis/commands/core.py:1717) which is a stub that unconditionally raises NotImplementedError. LATENCY DOCTOR returns a human-readable narrative report intended for the redis-cli, so the python client does not implement it. Related latency commands that ARE supported: latency_history, latency_latest, latency_reset. No arguments are accepted.

Solutions

  1. Use the structured equivalents: r.latency_latest() and r.latency_history(event) for machine-readable data
  2. Run 'redis-cli LATENCY DOCTOR' for the human-readable narrative
  3. If you must call it from python: r.execute_command("LATENCY", "DOCTOR")

Example fix

# before
r.latency_doctor()
# after
import pprint; pprint.pprint(r.latency_latest())
Defensive patterns

Strategy: fallback

Validate before calling

# latency_doctor() is intentionally unimplemented; use structured APIs
def latency_summary(r):
    return r.latency_latest()

Try / catch

try:
    r.latency_doctor()
except NotImplementedError:
    latest = r.latency_latest()

Prevention

When it happens

Trigger: Calling r.latency_doctor(). Any call raises immediately.

Common situations: Programmatic latency analysis where the developer reaches for a 'doctor' summary instead of the structured history/latest data.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/7aafa1c0c2dc567b. Report an issue: GitHub.

Appendix: source

Thrown at redis/commands/core.py:1717

        self: AsyncClientProtocol, **kwargs
    ) -> Awaitable[datetime.datetime]: ...

    def lastsave(self, **kwargs) -> datetime.datetime | Awaitable[datetime.datetime]:
        """
        Return a Python datetime object representing the last time the
        Redis database was saved to disk

        For more information, see https://redis.io/commands/lastsave
        """
        return self.execute_command("LASTSAVE", **kwargs)

    def latency_doctor(self):
        """Raise a NotImplementedError, as the client will not support LATENCY DOCTOR.
        This function is best used within the redis-cli.

        For more information, see https://redis.io/commands/latency-doctor
        """
        raise NotImplementedError(
            """
            LATENCY DOCTOR is intentionally not implemented in the client.

            For more information, see https://redis.io/commands/latency-doctor
            """
        )

    def latency_graph(self):
        """Raise a NotImplementedError, as the client will not support LATENCY GRAPH.
        This function is best used within the redis-cli.

        For more information, see https://redis.io/commands/latency-graph.
        """
        raise NotImplementedError(
            """
            LATENCY GRAPH is intentionally not implemented in the client.

            For more information, see https://redis.io/commands/latency-graph

View on GitHub (pinned to 6a6b581b48)