Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Last active November 12, 2021 02:01
Show Gist options
  • Save matthewpoer/10183d4ac7b75e8bf0fc48a8c7d0a759 to your computer and use it in GitHub Desktop.
Save matthewpoer/10183d4ac7b75e8bf0fc48a8c7d0a759 to your computer and use it in GitHub Desktop.
import time
barList = ["|","/","-","\\"]
barListIter = iter(barList)
ten_seconds_away = int(time.time()) + 10
while int(time.time()) < ten_seconds_away:
remaining = ten_seconds_away - int(time.time())
bar = next(barListIter, None)
if not bar:
barListIter = iter(barList)
bar = next(barListIter)
message=f"{bar} {remaining} seconds remaining".ljust(80)
print(message, end='\r', flush=True)
time.sleep(.25)
print(message, flush=True)
print("Job complete")
@matthewpoer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment