mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	(Merge 3.3) Close #19339: telnetlib module is now using time.monotonic() when
available to compute timeout.
This commit is contained in:
		
						commit
						ebca392a6c
					
				
					 2 changed files with 11 additions and 6 deletions
				
			
		|  | @ -36,6 +36,10 @@ | |||
| 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 @@ def read_until(self, match, timeout=None): | |||
|             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 @@ def read_until(self, match, timeout=None): | |||
|                         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 @@ def expect(self, list, timeout=None): | |||
|                 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 @@ def expect(self, list, timeout=None): | |||
|                         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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor Stinner
						Victor Stinner