Utility Classes¶
Enums¶
- class PureToken(*values)[source]¶
Bases:
CaseAndEncodingInsensitiveEnumEnum for using pure-tokens with the redis api.
- RESET = b'RESET'¶
Used by:
ACL LOG
- SCHEDULE = b'SCHEDULE'¶
Used by:
BGSAVE
- BIT = b'BIT'¶
Used by:
BITCOUNTBITPOS
- BYTE = b'BYTE'¶
Used by:
BITCOUNTBITPOS
- FAIL = b'FAIL'¶
Used by:
BITFIELD
- SAT = b'SAT'¶
Used by:
BITFIELD
- WRAP = b'WRAP'¶
Used by:
BITFIELD
- AND = b'AND'¶
Used by:
BITOP
- ANDOR = b'ANDOR'¶
Used by:
BITOP
- DIFF = b'DIFF'¶
Used by:
BITOP
- DIFF1 = b'DIFF1'¶
Used by:
BITOP
- NOT = b'NOT'¶
Used by:
BITOP
- ONE = b'ONE'¶
Used by:
BITOPREPLICAOFSLAVEOF
- OR = b'OR'¶
Used by:
BITOP
- XOR = b'XOR'¶
Used by:
BITOP
- LEFT = b'LEFT'¶
Used by:
BLMOVEBLMPOPLMOVELMPOP
- RIGHT = b'RIGHT'¶
Used by:
BLMOVEBLMPOPLMOVELMPOP
- MAX = b'MAX'¶
Used by:
BZMPOPFT.AGGREGATEFT.HYBRIDTS.ADDTS.ALTERTS.CREATETS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGEZINTERZINTERSTOREZMPOPZUNIONZUNIONSTORE
- MIN = b'MIN'¶
Used by:
BZMPOPFT.AGGREGATEFT.HYBRIDTS.ADDTS.ALTERTS.CREATETS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGEZINTERZINTERSTOREZMPOPZUNIONZUNIONSTORE
- NO = b'NO'¶
Used by:
CLIENT CACHINGCLIENT KILLREPLICAOFSCRIPT DEBUGSLAVEOF
- YES = b'YES'¶
Used by:
CLIENT CACHINGCLIENT KILLSCRIPT DEBUG
- MASTER = b'MASTER'¶
Used by:
CLIENT KILLCLIENT LIST
- NORMAL = b'NORMAL'¶
Used by:
CLIENT KILLCLIENT LIST
- PUBSUB = b'PUBSUB'¶
Used by:
CLIENT KILLCLIENT LIST
- REPLICA = b'REPLICA'¶
Used by:
CLIENT KILLCLIENT LIST
- SLAVE = b'SLAVE'¶
Used by:
CLIENT KILL
- OFF = b'OFF'¶
Used by:
CLIENT NO-EVICTCLIENT NO-TOUCHCLIENT REPLYCLIENT TRACKING
- ON = b'ON'¶
Used by:
CLIENT NO-EVICTCLIENT NO-TOUCHCLIENT REPLYCLIENT TRACKING
- ALL = b'ALL'¶
Used by:
CLIENT PAUSECLUSTER MIGRATION
- WRITE = b'WRITE'¶
Used by:
CLIENT PAUSE
- SKIP = b'SKIP'¶
Used by:
CLIENT REPLY
- BCAST = b'BCAST'¶
Used by:
CLIENT TRACKING
- NOLOOP = b'NOLOOP'¶
Used by:
CLIENT TRACKING
- OPTIN = b'OPTIN'¶
Used by:
CLIENT TRACKING
- OPTOUT = b'OPTOUT'¶
Used by:
CLIENT TRACKING
- ERROR = b'ERROR'¶
Used by:
CLIENT UNBLOCK
- TIMEOUT = b'TIMEOUT'¶
Used by:
CLIENT UNBLOCK
- FORCE = b'FORCE'¶
Used by:
CLUSTER FAILOVERFAILOVERSHUTDOWNXCLAIM
- TAKEOVER = b'TAKEOVER'¶
Used by:
CLUSTER FAILOVER
- HARD = b'HARD'¶
Used by:
CLUSTER RESET
- SOFT = b'SOFT'¶
Used by:
CLUSTER RESET
- STABLE = b'STABLE'¶
Used by:
CLUSTER SETSLOT
- ASC = b'ASC'¶
Used by:
CLUSTER SLOT-STATSFT.AGGREGATEFT.HYBRIDFT.SEARCHGEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORESORTSORT_RO
- DESC = b'DESC'¶
Used by:
CLUSTER SLOT-STATSFT.AGGREGATEFT.HYBRIDFT.SEARCHGEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORESORTSORT_RO
- SNAPSHOT_EOF = b'SNAPSHOT-EOF'¶
Used by:
CLUSTER SYNCSLOTS
- STREAM_EOF = b'STREAM-EOF'¶
Used by:
CLUSTER SYNCSLOTS
- REPLACE = b'REPLACE'¶
Used by:
COPYFUNCTION LOADFUNCTION RESTOREMIGRATERESTORERESTORE-ASKING
- GT = b'GT'¶
Used by:
EXPIREEXPIREATHEXPIREHEXPIREATHPEXPIREHPEXPIREATPEXPIREPEXPIREATZADD
- LT = b'LT'¶
Used by:
EXPIREEXPIREATHEXPIREHEXPIREATHPEXPIREHPEXPIREATPEXPIREPEXPIREATZADD
- NX = b'NX'¶
Used by:
EXPIREEXPIREATGEOADDHEXPIREHEXPIREATHPEXPIREHPEXPIREATJSON.SETMSETEXPEXPIREPEXPIREATSETZADD
- XX = b'XX'¶
Used by:
EXPIREEXPIREATGEOADDHEXPIREHEXPIREATHPEXPIREHPEXPIREATJSON.SETMSETEXPEXPIREPEXPIREATSETZADD
- ABORT = b'ABORT'¶
Used by:
FAILOVERSHUTDOWN
- ASYNC = b'ASYNC'¶
Used by:
FLUSHALLFLUSHDBFUNCTION FLUSHSCRIPT FLUSH
- SYNC = b'SYNC'¶
Used by:
FLUSHALLFLUSHDBFUNCTION FLUSHSCRIPT DEBUGSCRIPT FLUSH
- WITHCODE = b'WITHCODE'¶
Used by:
FUNCTION LIST
- APPEND = b'APPEND'¶
Used by:
FUNCTION RESTORE
- FLUSH = b'FLUSH'¶
Used by:
FUNCTION RESTORE
- CHANGE = b'CH'¶
Used by:
GEOADDZADD
- FT = b'FT'¶
Used by:
FT.SEARCHGEODISTGEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORE
- KM = b'KM'¶
Used by:
FT.SEARCHGEODISTGEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORE
- M = b'M'¶
Used by:
FT.SEARCHGEODISTGEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORE
- MI = b'MI'¶
Used by:
FT.SEARCHGEODISTGEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORE
- ANY = b'ANY'¶
Used by:
GEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCHGEOSEARCHSTORE
- WITHCOORD = b'WITHCOORD'¶
Used by:
GEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCH
- WITHDIST = b'WITHDIST'¶
Used by:
GEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCH
- WITHHASH = b'WITHHASH'¶
Used by:
GEORADIUSGEORADIUSBYMEMBERGEORADIUSBYMEMBER_ROGEORADIUS_ROGEOSEARCH
- STOREDIST = b'STOREDIST'¶
Used by:
GEOSEARCHSTORE
- PERSIST = b'PERSIST'¶
Used by:
GETEXHGETEX
- CPU = b'CPU'¶
Used by:
HOTKEYS START
- NET = b'NET'¶
Used by:
HOTKEYS START
- WITHVALUES = b'WITHVALUES'¶
Used by:
HRANDFIELD
- NOVALUES = b'NOVALUES'¶
Used by:
HSCAN
- FNX = b'FNX'¶
Used by:
HSETEX
- FXX = b'FXX'¶
Used by:
HSETEX
- KEEPTTL = b'KEEPTTL'¶
Used by:
HSETEXMSETEXSET
- IDX = b'IDX'¶
Used by:
LCS
- LEN = b'LEN'¶
Used by:
LCS
- WITHMATCHLEN = b'WITHMATCHLEN'¶
Used by:
LCS
- AFTER = b'AFTER'¶
Used by:
LINSERT
- BEFORE = b'BEFORE'¶
Used by:
LINSERT
- COPY = b'COPY'¶
Used by:
MIGRATE
- EMPTY_STRING = b''¶
Used by:
MIGRATE
- ABSTTL = b'ABSTTL'¶
Used by:
RESTORERESTORE-ASKING
- GET = b'GET'¶
Used by:
SET
- NOSAVE = b'NOSAVE'¶
Used by:
SHUTDOWN
- NOW = b'NOW'¶
Used by:
SHUTDOWN
- SAVE = b'SAVE'¶
Used by:
SHUTDOWN
- SORTING = b'ALPHA'¶
Used by:
SORTSORT_RO
- ACKED = b'ACKED'¶
Used by:
XACKDELXADDXDELEXXTRIM
- DELREF = b'DELREF'¶
Used by:
XACKDELXADDXDELEXXTRIM
- KEEPREF = b'KEEPREF'¶
Used by:
XACKDELXADDXDELEXXTRIM
- APPROXIMATELY = b'~'¶
Used by:
XADDXTRIM
- AUTO_ID = b'*'¶
Used by:
XADD
- EQUAL = b'='¶
Used by:
XADDXTRIM
- MAXLEN = b'MAXLEN'¶
Used by:
XADDXTRIM
- MINID = b'MINID'¶
Used by:
XADDXTRIM
- NOMKSTREAM = b'NOMKSTREAM'¶
Used by:
XADD
- JUSTID = b'JUSTID'¶
Used by:
XAUTOCLAIMXCLAIM
- MKSTREAM = b'MKSTREAM'¶
Used by:
XGROUP CREATE
- NEW_ID = b'$'¶
Used by:
XGROUP CREATEXGROUP SETID
- FULL = b'FULL'¶
Used by:
XINFO STREAM
- NOACK = b'NOACK'¶
Used by:
XREADGROUP
- INCREMENT = b'INCR'¶
Used by:
ZADD
- WITHSCORES = b'WITHSCORES'¶
Used by:
FT.SEARCHFT.SUGGETVLINKSVSIMZDIFFZINTERZRANDMEMBERZRANGEZRANGEBYSCOREZREVRANGEZREVRANGEBYSCOREZUNION
- SUM = b'SUM'¶
Used by:
FT.AGGREGATEFT.HYBRIDTS.ADDTS.ALTERTS.CREATETS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGEZINTERZINTERSTOREZUNIONZUNIONSTORE
- BYLEX = b'BYLEX'¶
Used by:
ZRANGEZRANGESTORE
- BYSCORE = b'BYSCORE'¶
Used by:
ZRANGEZRANGESTORE
- REV = b'REV'¶
Used by:
ZRANGEZRANGESTORE
- WITHSCORE = b'WITHSCORE'¶
Used by:
ZRANKZREVRANK
- BIN = b'BIN'¶
Used by:
VADD
- CAS = b'CAS'¶
Used by:
VADD
- FP32 = b'FP32'¶
Used by:
VADDVSIM
- NOQUANT = b'NOQUANT'¶
Used by:
VADD
- Q8 = b'Q8'¶
Used by:
VADD
- VALUES = b'VALUES'¶
Used by:
VADDVSIM
- ELE = b'ELE'¶
Used by:
VSIM
- NOTHREAD = b'NOTHREAD'¶
Used by:
VSIM
- TRUTH = b'TRUTH'¶
Used by:
VSIM
- WITHATTRIBS = b'WITHATTRIBS'¶
Used by:
VSIM
- RAW = b'RAW'¶
Used by:
VEMB
- NONSCALING = b'NONSCALING'¶
Used by:
BF.INSERTBF.RESERVE
- ITEMS = b'ITEMS'¶
Used by:
BF.INFOBF.INSERTCF.INSERTCF.INSERTNX
- NOCREATE = b'NOCREATE'¶
Used by:
BF.INSERTCF.INSERTCF.INSERTNX
- CAPACITY = b'CAPACITY'¶
Used by:
BF.INFO
- EXPANSION = b'EXPANSION'¶
Used by:
BF.INFO
- FILTERS = b'FILTERS'¶
Used by:
BF.INFO
- SIZE = b'SIZE'¶
Used by:
BF.INFO
- WEIGHTS = b'WEIGHTS'¶
Used by:
CMS.MERGE
- WITHCOUNT = b'WITHCOUNT'¶
Used by:
TOPK.LIST
- COMPRESSION = b'COMPRESSION'¶
Used by:
TDIGEST.MERGE
- OVERRIDE = b'OVERRIDE'¶
Used by:
TDIGEST.MERGE
- BLOCK = b'BLOCK'¶
Used by:
TS.ADDTS.ALTERTS.CREATE
- COMPRESSED = b'COMPRESSED'¶
Used by:
TS.ADDTS.CREATE
- FIRST = b'FIRST'¶
Used by:
TS.ADDTS.ALTERTS.CREATETS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- LAST = b'LAST'¶
Used by:
TS.ADDTS.ALTERTS.CREATETS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- UNCOMPRESSED = b'UNCOMPRESSED'¶
Used by:
TS.ADDTS.CREATETS.DECRBYTS.INCRBY
- AVG = b'AVG'¶
Used by:
FT.AGGREGATEFT.HYBRIDTS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- COUNT = b'COUNT'¶
Used by:
FT.AGGREGATEFT.HYBRIDTS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- COUNTALL = b'COUNTALL'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- COUNTNAN = b'COUNTNAN'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- RANGE = b'RANGE'¶
Used by:
FT.HYBRIDTS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- STD_P = b'STD.P'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- STD_S = b'STD.S'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- TWA = b'TWA'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- VAR_P = b'VAR.P'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- VAR_S = b'VAR.S'¶
Used by:
TS.CREATERULETS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- BUCKETTIMESTAMP = b'BUCKETTIMESTAMP'¶
Used by:
TS.MRANGETS.MREVRANGETS.RANGE
- EMPTY = b'EMPTY'¶
Used by:
TS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- FILTER_BY_VALUE = b'FILTER_BY_VALUE'¶
Used by:
TS.MRANGETS.MREVRANGETS.RANGETS.REVRANGE
- END = b'END'¶
Used by:
TS.REVRANGE
- HYPHEN_MINUS = b'-'¶
Used by:
TS.REVRANGE
- MID = b'MID'¶
Used by:
TS.REVRANGE
- PLUS_SIGN = b'+'¶
Used by:
TS.REVRANGE
- START = b'START'¶
Used by:
TS.REVRANGE
- TILDE = b'~'¶
Used by:
TS.REVRANGE
- GROUPBY = b'GROUPBY'¶
Used by:
FT.HYBRIDTS.MRANGETS.MREVRANGE
- SELECTED_LABELS = b'SELECTED_LABELS'¶
Used by:
TS.MGETTS.MRANGETS.MREVRANGE
- WITHLABELS = b'WITHLABELS'¶
Used by:
TS.MGETTS.MRANGETS.MREVRANGE
- LATEST = b'LATEST'¶
Used by:
TS.MREVRANGE
- DISABLE = b'DISABLE'¶
Used by:
FT.CREATE
- ENABLE = b'ENABLE'¶
Used by:
FT.CREATE
- GEO = b'GEO'¶
Used by:
FT.CREATE
- GEOSHAPE = b'GEOSHAPE'¶
Used by:
FT.CREATE
- HASH = b'HASH'¶
Used by:
FT.CREATE
- INDEXEMPTY = b'INDEXEMPTY'¶
Used by:
FT.CREATE
- INDEXMISSING = b'INDEXMISSING'¶
Used by:
FT.CREATE
- JSON = b'JSON'¶
Used by:
FT.CREATE
- MAXTEXTFIELDS = b'MAXTEXTFIELDS'¶
Used by:
FT.CREATE
- NOFIELDS = b'NOFIELDS'¶
Used by:
FT.CREATE
- NOFREQS = b'NOFREQS'¶
Used by:
FT.CREATE
- NOHL = b'NOHL'¶
Used by:
FT.CREATE
- NOINDEX = b'NOINDEX'¶
Used by:
FT.CREATE
- NOOFFSETS = b'NOOFFSETS'¶
Used by:
FT.CREATE
- NUMERIC = b'NUMERIC'¶
Used by:
FT.CREATE
- SCHEMA = b'SCHEMA'¶
Used by:
FT.ALTERFT.CREATE
- SKIPINITIALSCAN = b'SKIPINITIALSCAN'¶
Used by:
FT.ALTERFT.CREATEFT.SYNUPDATE
- SORTABLE = b'SORTABLE'¶
Used by:
FT.CREATE
- TAG = b'TAG'¶
Used by:
FT.CREATE
- TEXT = b'TEXT'¶
Used by:
FT.CREATE
- UNF = b'UNF'¶
Used by:
FT.CREATE
- VECTOR = b'VECTOR'¶
Used by:
FT.CREATE
- WITHSUFFIXTRIE = b'WITHSUFFIXTRIE'¶
Used by:
FT.CREATE
- ADD = b'ADD'¶
Used by:
FT.ALTER
- DELETE_DOCS = b'DD'¶
Used by:
FT.DROPINDEX
- EXCLUDE = b'EXCLUDE'¶
Used by:
FT.SPELLCHECK
- INCLUDE = b'INCLUDE'¶
Used by:
FT.SPELLCHECK
- EXPLAINSCORE = b'EXPLAINSCORE'¶
Used by:
FT.SEARCH
- HIGHLIGHT = b'HIGHLIGHT'¶
Used by:
FT.SEARCH
- INORDER = b'INORDER'¶
Used by:
FT.SEARCH
- LIMIT = b'LIMIT'¶
Used by:
FT.AGGREGATEFT.HYBRIDFT.SEARCH
- NOCONTENT = b'NOCONTENT'¶
Used by:
FT.SEARCH
- NOSTOPWORDS = b'NOSTOPWORDS'¶
Used by:
FT.SEARCH
- PARAMS = b'PARAMS'¶
Used by:
FT.AGGREGATEFT.HYBRIDFT.SEARCH
- SUMMARIZE = b'SUMMARIZE'¶
Used by:
FT.SEARCH
- TAGS = b'TAGS'¶
Used by:
FT.SEARCH
- VERBATIM = b'VERBATIM'¶
Used by:
FT.AGGREGATEFT.SEARCH
- WITHPAYLOADS = b'WITHPAYLOADS'¶
Used by:
FT.SEARCHFT.SUGGET
- WITHSORTKEYS = b'WITHSORTKEYS'¶
Used by:
FT.SEARCH
- COUNT_DISTINCT = b'COUNT_DISTINCT'¶
Used by:
FT.AGGREGATEFT.HYBRID
- COUNT_DISTINCTISH = b'COUNT_DISTINCTISH'¶
Used by:
FT.AGGREGATEFT.HYBRID
- FIRST_VALUE = b'FIRST_VALUE'¶
Used by:
FT.AGGREGATEFT.HYBRID
- LOADALL = b'LOAD *'¶
Used by:
FT.AGGREGATEFT.HYBRID
- QUANTILE = b'QUANTILE'¶
Used by:
FT.AGGREGATEFT.HYBRID
- RANDOM_SAMPLE = b'RANDOM_SAMPLE'¶
Used by:
FT.AGGREGATEFT.HYBRID
- REDUCE = b'REDUCE'¶
Used by:
FT.AGGREGATEFT.HYBRID
- STDDEV = b'STDDEV'¶
Used by:
FT.AGGREGATEFT.HYBRID
- TOLIST = b'TOLIST'¶
Used by:
FT.AGGREGATEFT.HYBRID
- WITHCURSOR = b'WITHCURSOR'¶
Used by:
FT.AGGREGATE
- AGGREGATE = b'AGGREGATE'¶
Used by:
FT.PROFILE
- HYBRID = b'HYBRID'¶
Used by:
FT.PROFILE
- LIMITED = b'LIMITED'¶
Used by:
FT.PROFILE
- QUERYWORD = b'QUERY'¶
Used by:
FT.PROFILE
- SEARCH = b'SEARCH'¶
Used by:
FT.HYBRIDFT.PROFILE
- ADHOC = b'ADHOC'¶
Used by:
FT.HYBRID
- BATCHES = b'BATCHES'¶
Used by:
FT.HYBRID
- COMBINE = b'COMBINE'¶
Used by:
FT.HYBRID
- KNN = b'KNN'¶
Used by:
FT.HYBRID
- LINEAR = b'LINEAR'¶
Used by:
FT.HYBRID
- NOSORT = b'NOSORT'¶
Used by:
FT.HYBRID
- RRF = b'RRF'¶
Used by:
FT.HYBRID
- VSIM = b'VSIM'¶
Used by:
FT.HYBRID
- INCR = b'INCR'¶
Used by:
FT.SUGADD
- FUZZY = b'FUZZY'¶
Used by:
FT.SUGGET
Retrying¶
coredis.retry
Utilities for managing errors that can be recovered from by providing retry policies.
- class ConstantRetryPolicy(retryable_exceptions: tuple[type[BaseException], ...], retries: int | None, *, deadline: float = math.inf, delay: float = 1)[source]¶
Retry policy that pauses
delayseconds betweenretriesattempts or untildeadlineis met if any ofretryable_exceptionsare encountered.- Parameters:
retryable_exceptions¶ – The exceptions to trigger a retry for
retries¶ – number of times to retry if a
retryable_exceptionis encountered.deadline¶ – Stop retrying when the time from the first attempt > deadline
Warning
If
retriesisNoneand deadline ismath.infthis policy effectively becomes an infinite retry policy.- delay(attempt_number: int) float[source]¶
Returns the amount of time to pause after the
attempt_numberattempt
- async call_with_retries(func: Callable[[...], Awaitable[R]], before_hook: Callable[[...], Awaitable[Any] | None] | None = None, failure_hook: Callable[[...], Awaitable[Any] | None] | dict[type[BaseException], Callable[[...], Awaitable[Any] | None]] | None = None) R¶
- Parameters:
func¶ – a function that should return the coroutine that will be awaited when retrying if
RetryPolicy.retryable_exceptionsis encountered.before_hook¶ – if provided will be called on every attempt.
failure_hook¶ – if provided and is a callable it will be called after catching any retryable exception and before retrying. If it is a mapping of exception types to callables, the first exception type that is a parent of any encountered exception will be called.
- class ExponentialBackoffRetryPolicy(retryable_exceptions: tuple[type[BaseException], ...], retries: int | None, *, deadline: float = math.inf, base_delay: float = 1, max_delay: float = math.inf, jitter: bool = False)[source]¶
Retry policy that exponentially backs off before retrying up to
retriesordeadlineif any ofretryable_exceptionsare encountered.base_delayis used as the base value for calculating the exponential backoff given the attempt.For example with
base_delay== 1:attempt 1 = 2^(1-1)*1 == 1 attempt 2 = 2^(2-1)*1 == 2 attempt 3 = 2^(3-1)*1 == 4
To cap the delay to a maximum value, use
max_delay.If
jitteris true the delay will be randomly varied betweenbase_delayand the exponential delay for the given attempt- Parameters:
retryable_exceptions¶ – The exceptions to trigger a retry for
retries¶ – number of times to retry if a
retryable_exceptionis encountered.deadline¶ – Stop retrying when the time from the first attempt > deadline
Warning
If
retriesisNoneand deadline ismath.infthis policy effectively becomes an infinite retry policy.- delay(attempt_number: int) float[source]¶
Returns the amount of time to pause after the
attempt_numberattempt
- async call_with_retries(func: Callable[[...], Awaitable[R]], before_hook: Callable[[...], Awaitable[Any] | None] | None = None, failure_hook: Callable[[...], Awaitable[Any] | None] | dict[type[BaseException], Callable[[...], Awaitable[Any] | None]] | None = None) R¶
- Parameters:
func¶ – a function that should return the coroutine that will be awaited when retrying if
RetryPolicy.retryable_exceptionsis encountered.before_hook¶ – if provided will be called on every attempt.
failure_hook¶ – if provided and is a callable it will be called after catching any retryable exception and before retrying. If it is a mapping of exception types to callables, the first exception type that is a parent of any encountered exception will be called.
- class CompositeRetryPolicy(*retry_policies: RetryPolicy)[source]¶
Convenience class to combine multiple retry policies
- Parameters:
retryable_exceptions¶ – The exceptions to trigger a retry for
retries¶ – number of times to retry if a
retryable_exceptionis encountered.deadline¶ – Stop retrying when the time from the first attempt > deadline
Warning
If
retriesisNoneand deadline ismath.infthis policy effectively becomes an infinite retry policy.- add_retry_policy(policy: RetryPolicy) None[source]¶
Add to the retry policies that this instance was created with
- delay(attempt_number: int) float[source]¶
Returns the amount of time to pause after the
attempt_numberattempt
- async call_with_retries(func: Callable[[...], Awaitable[R]], before_hook: Callable[[...], Awaitable[Any] | None] | None = None, failure_hook: None | Callable[[...], Awaitable[Any] | None] | dict[type[BaseException], Callable[[...], Awaitable[Any] | None]] = None) R[source]¶
Calls
funcrepeatedly according to the retry policies that this class was instantiated with (CompositeRetryPolicy.retry_policies).- Parameters:
func¶ – a function that should return the coroutine that will be awaited when retrying if
RetryPolicy.retryable_exceptionsis encountered.before_hook¶ – if provided will be called before every attempt.
failure_hook¶ – if provided and is a callable it will be called after catching any retryable exception and before retrying. If it is a mapping of exception types to callables, the first exception type that is a parent of any encountered exception will be called.
- retryable(policy: RetryPolicy, failure_hook: Callable[[...], Awaitable[Any] | None] | dict[type[BaseException], Callable[[...], Awaitable[Any] | None]] | None = None) Callable[[Callable[[P], Awaitable[R]]], Callable[[P], Awaitable[R]]][source]¶
Decorator to be used to apply a retry policy to a coroutine
All retry policies need to derive from coredis.retry.RetryPolicy
- class RetryPolicy(retryable_exceptions: tuple[type[BaseException], ...], retries: int | None, *, deadline: float = math.inf)[source]¶
Abstract retry policy
- abstractmethod delay(attempt_number: int) float[source]¶
Returns the amount of time to pause after the
attempt_numberattempt
- async call_with_retries(func: Callable[[...], Awaitable[R]], before_hook: Callable[[...], Awaitable[Any] | None] | None = None, failure_hook: Callable[[...], Awaitable[Any] | None] | dict[type[BaseException], Callable[[...], Awaitable[Any] | None]] | None = None) R[source]¶
- Parameters:
func¶ – a function that should return the coroutine that will be awaited when retrying if
RetryPolicy.retryable_exceptionsis encountered.before_hook¶ – if provided will be called on every attempt.
failure_hook¶ – if provided and is a callable it will be called after catching any retryable exception and before retrying. If it is a mapping of exception types to callables, the first exception type that is a parent of any encountered exception will be called.