⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.159
Server IP:
97.74.87.16
Server:
Linux 16.87.74.97.host.secureserver.net 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
opt
/
nydus
/
ops
/
primordial
/
__pycache__
/
View File Name :
flow.cpython-39.pyc
a ���g� � @ s� d dl Z d dlmZ d dlmZmZmZmZmZ dZ dZ e �e�Z G dd� de�Zdeeeeed �dd�Zdd d� e efeeeeeee eee f ed�dd�ZdS )� N)�sleep)�Any�Callable�Tuple�Type�Uniong �?� c @ s e Zd ZdZdS )� RetryErrorz9A special type which signals the failure of a retry loop.N)�__name__� __module__�__qualname__�__doc__� r r �@/opt/nydus/tmp/pip-target-mke_irhy/lib/python/primordial/flow.pyr s r � � �?)� test_function� max_tests� sleep_secs�count_trues�returnc C s~ d}d}d}||kr"t �d� |}||k r\| � }|du rJ|d7 }||krJq\|d7 }t|� q"||k rttd|| f ��|||fS )a� Attempt test_function over and over, waiting for a true value. Try a maximum of max_tests times. Sleep sleep_secs in between each test. Receive count_trues before moving on. wait_for_true is designed specifically to handle a design principle behind AWS or other clustered services: that you might succeed when making a request once and then fail very soon after. For example, when you make a REST API call against S3 to see if a bucket exists, the fact that you get a "True" response does not guarantee that you will get that same response to a request made very soon after. In other words, it's for cases in which the goal is to produce a wait time for an eventually consistent external service to resolve your request. That's why wait_for_true lets you specify a threshold of how many trues you want to get before you're satisfied. :param test_function: a function to run whose result we will test for truthiness :param max_tests: limit to how many times we'll try test_function :param sleep_secs: how long to wait between tests :param count_trues: how many true results we need until we're totally true; this is useful with e.g. cluster tests, where we want a quorum of true answers before we're happy that the entire cluster is consistent (e.g. s3 put) :returns: the return value of the test function, the number of time it tried, and how many true results it found :raises RetryError: if the function "never" returned sufficiently many trues r Nz9count_trues > max_tests, bumping max_tests to count_truesT� z6wait_for_true never succeeded %s times for function %s)�LOGGER�warningr r )r r r r Z itercount�retZtruesr r r � wait_for_true s"