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)
| 33 | |
| 34 | |
| 35 | def 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 | |
| 64 | def setup_bucket(bucket_name, script_file_name, script_key, s3_resource): |
no outgoing calls
no test coverage detected