hyb
2025-11-10 e0a856b5072c5a09f3f6de6da85abf90e00ee704
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Ë
 
çúhêãó”—ddlZddlZddlmZmZddlmZmZddlmZm    Z    ddl
m Z ddl m ZdZdZd    ZGd
„d e«ZGd „d e«Zy)éN)ÚABCÚabstractmethod)ÚdatetimeÚ    timedelta)ÚListÚType)ÚOptional)ÚStateiègš™™™™™¹?écóV—eZdZedededdfd„«Zededdfd„«Zedd„«Zy)    ÚFailureDetectorÚ    exceptionÚcmdÚreturnNcó—y)z:Register a failure that occurred during command execution.N©©Úselfrrs   õqH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\redis/multidb/failure_detector.pyÚregister_failurez FailureDetector.register_failureó€ð     ócó—y)zRegister a command execution.Nr©rrs  rÚregister_command_executionz*FailureDetector.register_command_executionrrcó—y)z*Set the command executor for this failure.Nr©rÚcommand_executors  rÚset_command_executorz$FailureDetector.set_command_executorrr©rN)    Ú__name__Ú
__module__Ú __qualname__rÚ    ExceptionÚtuplerrrrrrr r s_„Øð ¨)ð ¸%ð ÀDò óð ðð ¨eð ¸ò óð ðò óñ rr c ó‚—eZdZdZeeedfdededede    e
e e ddf
d„Z d    e d
eddfd „Zdd „Zd
eddfd „Zd„Zdd„Zy)ÚCommandFailureDetectorze
    Detects a failure based on a threshold of failed commands during a specific period of time.
    NÚmin_num_failuresÚfailure_rate_thresholdÚfailure_detection_windowÚ error_typesrcó—d|_||_||_||_||_d|_t j«|_|jt|j¬«z|_
d|_ tj«|_y)az
        Initialize a new CommandFailureDetector instance.
 
        Args:
            min_num_failures: Minimal count of failures required for failover
            failure_rate_threshold: Percentage of failures required for failover
            failure_detection_window: Time interval for executing health checks.
            error_types: Optional list of exception types to trigger failover. If None, all exceptions are counted.
 
        The detector tracks command failures within a sliding time window. When the number of failures
        exceeds the threshold within the specified duration, it triggers failure detection.
        Nr©Úseconds)Ú_command_executorÚ_min_num_failuresÚ_failure_rate_thresholdÚ_failure_detection_windowÚ _error_typesÚ_commands_executedrÚnowÚ _start_timerÚ    _end_timeÚ_failures_countÚ    threadingÚRLockÚ_lock)rr(r)r*r+s     rÚ__init__zCommandFailureDetector.__init__&s|€ð&"&ˆÔØ!1ˆÔØ'=ˆÔ$Ø)AˆÔ&Ø'ˆÔØ'(ˆÔÜ%-§\¡\£^ˆÔØ#'×#3Ñ#3´iØ×2Ñ2ô7
ñ$
ˆŒð%&ˆÔÜ—_‘_Ó&ˆ
rrrcó—|j5|jr-t|«|jvr+|xjdz c_n|xjdz c_|j    «ddd«y#1swYyxYw©Né)r;r3Útyper8Ú_check_thresholdrs   rrz'CommandFailureDetector.register_failureFsg€Ø Z‰Zñ    $Ø× Ò Ü˜    “? d×&7Ñ&7Ñ7Ø×(Ò(¨AÑ-Ö(à×$Ò$¨Ñ)Õ$à × !Ñ !Ô #÷    $÷    $ñ    $ús AA5Á5A>có—||_y©N)r/rs  rrz+CommandFailureDetector.set_command_executorPs
€Ø!1ˆÕrcóö—|j5|jtj«cxkr|jksn|j «|xj dz c_ddd«y#1swYyxYwr>)r;r6rr5r7Ú_resetr4rs  rrz1CommandFailureDetector.register_command_executionSsU€Ø Z‰Zñ    )Ø×#Ñ#¤h§l¡l£nÔE°t·~±~ÔEØ— ‘ ” à × #Ò # qÑ (Õ #÷        )÷    )ñ    )ús AA/Á/A8có2—|j|jk\r~|jtj|j|j
z«k\rDt j|jjj_ |j«yyyrC) r8r0ÚmathÚceilr4r1ÚCBStateÚOPENr/Úactive_databaseÚcircuitÚstaterE©rs rrAz'CommandFailureDetector._check_thresholdZss€Ø × Ñ  4×#9Ñ#9Ò 9¸d×>RÑ>RÜ I‰Id×-Ñ-°×0LÑ0LÑLÓ Mò?
ôDKÇ<Á<ˆD× "Ñ "× 2Ñ 2× :Ñ :Ô @Ø K‰KMð    ?
Ð 9rcóä—|j5tj«|_|jt    |j
¬«z|_d|_d|_ddd«y#1swYyxYw)Nr-r)    r;rr5r6rr2r7r8r4rNs rrEzCommandFailureDetector._resetas`€Ø Z‰Zñ    (Ü'Ÿ|™|›~ˆDÔ Ø!×-Ñ-´    Ø×6Ñ6ô1ñˆDŒNð$%ˆDÔ  Ø&'ˆDÔ #÷     (÷    (ñ    (ús AA&Á&A/r )r!r"r#Ú__doc__ÚDEFAULT_MIN_NUM_FAILURESÚDEFAULT_FAILURE_RATE_THRESHOLDÚ!DEFAULT_FAILURES_DETECTION_WINDOWÚintÚfloatr    rrr$r<r%rrrrArErrrr'r'!s•„ñð !9Ø(FØ*KØ7;ñ 'àð'ð!&ð'ð#(ð    'ð
˜d 4¨    ¡?Ñ3Ñ4ð 'ð
ó 'ð@$¨)ð$¸%ð$ÀDó$ó2ð)¨eð)¸ó)òô(rr')rGr9ÚabcrrrrÚtypingrrÚtyping_extensionsr    Úredis.multidb.circuitr
rIrQrRrSr r'rrrú<module>rZsFðÛ Ûß#ß(ßå&å2àÐØ!$ÐØ$%Ð!ô cô ô"G(˜_õG(r