Skip to content

Commit

Permalink
Merge pull request #8 from vitormhenrique/master
Browse files Browse the repository at this point in the history
Update dhcp.py
  • Loading branch information
niccokunzmann authored Dec 28, 2018
2 parents 4888142 + 3d1eb63 commit 58e9b01
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions server/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,17 @@ def __init__(self):

def _delay_response_thread(self):
while not self.closed:
p = self.queue.get()
if self.closed:
break
t, func, args, kw = p
now = time.time()
if now < t:
time.sleep(0.01)
self.queue.put(p)
else:
func(*args, **kw)
if not self.queue.empty():
p = self.queue.get()
t, func, args, kw = p
now = time.time()
if now < t:
time.sleep(0.01)
self.queue.put(p)
else:
func(*args, **kw)

def do_after(self, seconds, func, args = (), kw = {}):
self.queue.put((time.time() + seconds, func, args, kw))
Expand Down

0 comments on commit 58e9b01

Please sign in to comment.