Attempt to terminate threads when pyfa is closed

This commit is contained in:
DarkPhoenix
2020-02-03 17:12:23 +03:00
parent 9ddfcc894f
commit 6527f9e11e
7 changed files with 99 additions and 18 deletions

View File

@@ -35,3 +35,16 @@ class Timer:
def __exit__(self, type, value, traceback):
self.checkpoint('finished')
pass
class CountdownTimer:
def __init__(self, timeout):
self.timeout = timeout
self.start = time.time()
def elapsed(self):
return time.time() - self.start
def remainder(self):
return max(self.timeout - self.elapsed(), 0)