MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / status_poller

Function status_poller

python/example_code/emr/emr_usage_demo.py:35–61  ·  view source on GitHub ↗

Polls a function for status, sleeping for 10 seconds between each query, until the specified status is returned. :param intro: An introductory sentence that informs the reader what we're waiting for. :param done_status: The status we're waiting for. This function

(intro, done_status, func)

Source from the content-addressed store, hash-verified

33
34
35def status_poller(intro, done_status, func):
36 """
37 Polls a function for status, sleeping for 10 seconds between each query,
38 until the specified status is returned.
39
40 :param intro: An introductory sentence that informs the reader what we're
41 waiting for.
42 :param done_status: The status we're waiting for. This function polls the status
43 function until it returns the specified status.
44 :param func: The function to poll for status. This function must eventually
45 return the expected done_status or polling will continue indefinitely.
46 """
47 emr_basics.logger.setLevel(logging.WARNING)
48 status = None
49 print(intro)
50 print("Current status: ", end="")
51 while status != done_status:
52 prev_status = status
53 status = func()
54 if prev_status == status:
55 print(".", end="")
56 else:
57 print(status, end="")
58 sys.stdout.flush()
59 time.sleep(10)
60 print()
61 emr_basics.logger.setLevel(logging.INFO)
62
63
64def setup_bucket(bucket_name, script_file_name, script_key, s3_resource):

Callers 3

add_top_product_stepFunction · 0.85
demo_short_lived_clusterFunction · 0.85
demo_long_lived_clusterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected