mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Whitespace normalization.
This commit is contained in:
parent
a86f0c17a1
commit
b64bec3ec0
8 changed files with 18 additions and 21 deletions
|
@ -489,12 +489,12 @@ def Timer(*args, **kwargs):
|
|||
|
||||
class _Timer(Thread):
|
||||
"""Call a function after a specified number of seconds:
|
||||
|
||||
|
||||
t = Timer(30.0, f, args=[], kwargs={})
|
||||
t.start()
|
||||
t.cancel() # stop the timer's action if it's still waiting
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, interval, function, args=[], kwargs={}):
|
||||
Thread.__init__(self)
|
||||
self.interval = interval
|
||||
|
@ -502,11 +502,11 @@ class _Timer(Thread):
|
|||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.finished = Event()
|
||||
|
||||
|
||||
def cancel(self):
|
||||
"""Stop the timer if it hasn't finished yet"""
|
||||
self.finished.set()
|
||||
|
||||
|
||||
def run(self):
|
||||
self.finished.wait(self.interval)
|
||||
if not self.finished.isSet():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue