Skip to content

Commit

Permalink
Cleanup Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
0x9900 committed Jun 1, 2024
1 parent a71573f commit 51d6093
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions dxcluster/_dxcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,7 @@ def run(self) -> None:

class Timer:
def __init__(self, max_time):
self.cur_time = int(time.time())
self.max_time = self.cur_time + max_time
self.max_time = self.current_time + max_time

def __iter__(self):
return self
Expand All @@ -534,11 +533,14 @@ def reduce(self):
self.max_time /= 2

def __next__(self):
self.cur_time = int(time.time())
if self.cur_time > self.max_time:
if self.current_time > self.max_time:
raise StopIteration
return True

@property
def current_time(self):
return time.time()


class QueueIterator:
def __init__(self, queue):
Expand Down

0 comments on commit 51d6093

Please sign in to comment.