Add interrupt handler and finishing logic
This commit is contained in:
@@ -92,6 +92,7 @@ def main():
|
|||||||
synctime = time.perf_counter() + startup_delay
|
synctime = time.perf_counter() + startup_delay
|
||||||
|
|
||||||
# Play da notes
|
# Play da notes
|
||||||
|
try:
|
||||||
while remaining_iterations > 0:
|
while remaining_iterations > 0:
|
||||||
for i, key in enumerate(sequence):
|
for i, key in enumerate(sequence):
|
||||||
while time.perf_counter() < synctime + lastbeat:
|
while time.perf_counter() < synctime + lastbeat:
|
||||||
@@ -105,5 +106,10 @@ def main():
|
|||||||
print(" ", end="", flush=True)
|
print(" ", end="", flush=True)
|
||||||
remaining_iterations -= 1
|
remaining_iterations -= 1
|
||||||
print(f"~ ({remaining_iterations} remaining)")
|
print(f"~ ({remaining_iterations} remaining)")
|
||||||
|
except KeyboardInterrupt as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
print(f"Total iterations: {args.iterations - remaining_iterations}")
|
||||||
|
return 0
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user