Waits for a specified number of seconds, while also displaying an animated spinner. :param seconds: The number of seconds to wait. :param tick: The number of frames per second used to animate the spinner.
(seconds, tick=12)
| 13 | |
| 14 | |
| 15 | def wait(seconds, tick=12): |
| 16 | """ |
| 17 | Waits for a specified number of seconds, while also displaying an animated |
| 18 | spinner. |
| 19 | |
| 20 | :param seconds: The number of seconds to wait. |
| 21 | :param tick: The number of frames per second used to animate the spinner. |
| 22 | """ |
| 23 | progress = "|/-\\" |
| 24 | waited = 0 |
| 25 | while waited < seconds: |
| 26 | for frame in range(tick): |
| 27 | sys.stdout.write(f"\r{progress[frame % len(progress)]}") |
| 28 | sys.stdout.flush() |
| 29 | time.sleep(1 / tick) |
| 30 | waited += 1 |
| 31 | sys.stdout.write("\r") |
| 32 | sys.stdout.flush() |
| 33 | |
| 34 | |
| 35 | class ExponentialRetry: |
no test coverage detected