Skip to content

Commit bb3504c

Browse files
committed
I forgot to git add .
1 parent 7817a17 commit bb3504c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

XRPLib/timeout.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import time
2+
3+
class Timeout:
4+
def __init__(self, timeout):
5+
"""
6+
Starts a timer that will expire after the given timeout.
7+
8+
: param timeout: The timeout, in seconds
9+
: type timeout: float
10+
"""
11+
self.timeout = timeout
12+
self.start_time = time.monotonic()
13+
14+
def is_done(self):
15+
"""
16+
: return: True if the timeout has expired, False otherwise
17+
"""
18+
if self.timeout is None:
19+
return False
20+
return time.monotonic() - self.start_time > self.timeout

0 commit comments

Comments
 (0)