Fix: `Delay()` stuck when `Ctrl+C` pressed (#92)

fix: #89

---
Co-authored-by: NyaMisty <gyc990326@gmail.com>
pull/475/head
yzqzss 1 year ago committed by GitHub
parent f57f50f7f2
commit 163fd9677b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,14 +11,10 @@ class Delay:
ellipses: str = "."
def animate(self):
try:
while not self.done:
sys.stdout.write("\r " + self.ellipses)
sys.stdout.flush()
self.ellipses += "."
time.sleep(0.1)
except KeyboardInterrupt:
sys.exit()
while not self.done:
print("\r" + self.ellipses, end="")
self.ellipses += "."
time.sleep(0.1)
def __init__(self, config: Config=None, session=None):
"""Add a delay if configured for that"""
@ -26,13 +22,10 @@ class Delay:
self.done = False
ellipses_animation = threading.Thread(target=self.animate)
ellipses_animation.daemon = True
ellipses_animation.start()
# sys.stdout.write("\rSleeping %.2f seconds..." % (config.delay))
# sys.stdout.flush()
time.sleep(config.delay)
self.done = True
sys.stdout.write("\r \r")
sys.stdout.flush()
print("\r \r", end="")

Loading…
Cancel
Save