redis/redis-py · error · NotImplementedError
LATENCY HISTOGRAM is intentionally not implemented in the cl
Error message
LATENCY HISTOGRAM is intentionally not implemented in the client.
What it means
latency_histogram is a stub that always raises NotImplementedError. Note: this is distinct from the TIMESERIES module's TS MRANGE aggregation or the Redis latency-event histogram. The method exists as a placeholder but does not invoke the server. Use execute_command if the underlying COMMAND LATENCY HISTOGRAM is available on your Redis version.
Source
Thrown at redis/commands/core.py:1964
def memory_purge(self: SyncClientProtocol, **kwargs) -> bool: ...
@overload
def memory_purge(self: AsyncClientProtocol, **kwargs) -> Awaitable[bool]: ...
def memory_purge(self, **kwargs) -> bool | Awaitable[bool]:
"""
Attempts to purge dirty pages for reclamation by allocator
For more information, see https://redis.io/commands/memory-purge
"""
return self.execute_command("MEMORY PURGE", **kwargs)
def latency_histogram(self, *args):
"""
This function throws a NotImplementedError since it is intentionally
not supported.
"""
raise NotImplementedError(
"LATENCY HISTOGRAM is intentionally not implemented in the client."
)
@overload
def latency_history(self: SyncClientProtocol, event: str) -> list[list[int]]: ...
@overload
def latency_history(
self: AsyncClientProtocol, event: str
) -> Awaitable[list[list[int]]]: ...
def latency_history(
self, event: str
) -> list[list[int]] | Awaitable[list[list[int]]]:
"""
Returns the raw data of the ``event``'s latency spikes time series.
For more information, see https://redis.io/commands/latency-historyView on GitHub (pinned to da03cdc7e8)
Solutions
- Use r.execute_command('COMMAND', 'LATENCY') if your Redis version exposes command-latency stats.
- For per-event latency spikes, use r.latency_history(event).
- For aggregate command stats, parse r.info('commandstats').
Example fix
# before
r.latency_histogram('GET')
# after
r.execute_command('COMMAND', 'LATENCY') # if supported by server Defensive patterns
Strategy: fallback
Try / catch
try:
r.latency_histogram()
except NotImplementedError:
stats = r.execute_command('COMMAND', 'LATENCY') Prevention
- latency_histogram is an intentional stub — don't rely on it.
- Distinguish command-latency stats from per-event latency history.
When it happens
Trigger: Calling r.latency_histogram() or r.latency_histogram('GET'). Confusing it with per-event latency history (latency_history).
Common situations: Developer expects command-latency percentile data. Confusing latency_histogram with the INFO commandstats output. Migrating from another client library that implemented it.
Related errors
- LATENCY DOCTOR is intentionally not implemented in the clien
- LATENCY GRAPH is intentionally not implemented in the client
- COMMAND INFO is intentionally not implemented in the client.
- COMMAND DOCS is intentionally not implemented in the client.
- MEMORY DOCTOR is intentionally not implemented in the client
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/ee8aae5533d9ed9e.json.
Report an issue: GitHub.