summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-10-26 07:20:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-10-26 07:20:38 (GMT)
commitebca392a6cb2aa7369e18ad29b31a712f861fa2a (patch)
treeed4929703205d72f4d1e2c8fa68ea77e53b23f8e /Lib
parent0ddaed345615e48b5910f17ff70bd5ce74cd1e5f (diff)
parent2ff68dd526c5e9bf5ace14299c90ecfd4c762333 (diff)
downloadcpython-ebca392a6cb2aa7369e18ad29b31a712f861fa2a.zip
cpython-ebca392a6cb2aa7369e18ad29b31a712f861fa2a.tar.gz
cpython-ebca392a6cb2aa7369e18ad29b31a712f861fa2a.tar.bz2
(Merge 3.3) Close #19339: telnetlib module is now using time.monotonic() when
available to compute timeout.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/telnetlib.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index fa23be0..0cacac8 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -36,6 +36,10 @@ To do:
import sys
import socket
import selectors
+try:
+ from time import monotonic as _time
+except ImportError:
+ from time import time as _time
__all__ = ["Telnet"]
@@ -304,8 +308,7 @@ class Telnet:
self.cookedq = self.cookedq[i:]
return buf
if timeout is not None:
- from time import time
- deadline = time() + timeout
+ deadline = _time() + timeout
with _TelnetSelector() as selector:
selector.register(self, selectors.EVENT_READ)
while not self.eof:
@@ -320,7 +323,7 @@ class Telnet:
self.cookedq = self.cookedq[i:]
return buf
if timeout is not None:
- timeout = deadline - time()
+ timeout = deadline - _time()
if timeout < 0:
break
return self.read_very_lazy()
@@ -610,8 +613,7 @@ class Telnet:
if not re: import re
list[i] = re.compile(list[i])
if timeout is not None:
- from time import time
- deadline = time() + timeout
+ deadline = _time() + timeout
with _TelnetSelector() as selector:
selector.register(self, selectors.EVENT_READ)
while not self.eof:
@@ -625,7 +627,7 @@ class Telnet:
return (i, m, text)
if timeout is not None:
ready = selector.select(timeout)
- timeout = deadline - time()
+ timeout = deadline - _time()
if not ready:
if timeout < 0:
break