From a43773e26cb056bc1db6392f2ffa9dedcabd4548 Mon Sep 17 00:00:00 2001 From: "Michael P. Soulier" Date: Sat, 23 Jul 2011 20:05:03 -0400 Subject: [PATCH] Fixing issue #16 on github, server failing to use timeout time in checkTimeout() method. --- tftpy/TftpStates.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tftpy/TftpStates.py b/tftpy/TftpStates.py index 0992d6c..6e6a84c 100644 --- a/tftpy/TftpStates.py +++ b/tftpy/TftpStates.py @@ -76,6 +76,7 @@ class TftpContext(object): self.packethook = None self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.settimeout(timeout) + self.timeout = timeout self.state = None self.next_block = 0 self.factory = TftpPacketFactory() @@ -105,9 +106,9 @@ class TftpContext(object): def checkTimeout(self, now): """Compare current time with last_update time, and raise an exception - if we're over SOCK_TIMEOUT time.""" + if we're over the timeout time.""" log.debug("checking for timeout on session %s" % self) - if now - self.last_update > SOCK_TIMEOUT: + if now - self.last_update > self.timeout: raise TftpTimeout, "Timeout waiting for traffic" def start(self):