Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(44)

Side by Side Diff: Lib/telnetlib.py

Issue 22043: Use a monotonic clock to compute timeouts
Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/subprocess.py ('k') | Lib/test/test_selectors.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 r"""TELNET client class. 1 r"""TELNET client class.
2 2
3 Based on RFC 854: TELNET Protocol Specification, by J. Postel and 3 Based on RFC 854: TELNET Protocol Specification, by J. Postel and
4 J. Reynolds 4 J. Reynolds
5 5
6 Example: 6 Example:
7 7
8 >>> from telnetlib import Telnet 8 >>> from telnetlib import Telnet
9 >>> tn = Telnet('www.python.org', 79) # connect to finger port 9 >>> tn = Telnet('www.python.org', 79) # connect to finger port
10 >>> tn.write(b'guido\r\n') 10 >>> tn.write(b'guido\r\n')
(...skipping 18 matching lines...) Expand all
29 - timeout should be intrinsic to the connection object instead of an 29 - timeout should be intrinsic to the connection object instead of an
30 option on one of the read calls only 30 option on one of the read calls only
31 31
32 """ 32 """
33 33
34 34
35 # Imported modules 35 # Imported modules
36 import sys 36 import sys
37 import socket 37 import socket
38 import selectors 38 import selectors
39 try: 39 from time import monotonic as _time
40 from time import monotonic as _time
41 except ImportError:
42 from time import time as _time
43 40
44 __all__ = ["Telnet"] 41 __all__ = ["Telnet"]
45 42
46 # Tunable parameters 43 # Tunable parameters
47 DEBUGLEVEL = 0 44 DEBUGLEVEL = 0
48 45
49 # Telnet protocol defaults 46 # Telnet protocol defaults
50 TELNET_PORT = 23 47 TELNET_PORT = 23
51 48
52 # Telnet protocol characters (don't change) 49 # Telnet protocol characters (don't change)
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 except ValueError: 660 except ValueError:
664 port = socket.getservbyname(portstr, 'tcp') 661 port = socket.getservbyname(portstr, 'tcp')
665 tn = Telnet() 662 tn = Telnet()
666 tn.set_debuglevel(debuglevel) 663 tn.set_debuglevel(debuglevel)
667 tn.open(host, port, timeout=0.5) 664 tn.open(host, port, timeout=0.5)
668 tn.interact() 665 tn.interact()
669 tn.close() 666 tn.close()
670 667
671 if __name__ == '__main__': 668 if __name__ == '__main__':
672 test() 669 test()
OLDNEW
« no previous file with comments | « Lib/subprocess.py ('k') | Lib/test/test_selectors.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7