mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Patch #825417: Fix timeout processing in expect,
read_until. Will backport to 2.4.
This commit is contained in:
		
							parent
							
								
									4548239e2b
								
							
						
					
					
						commit
						ede77f5373
					
				
					 2 changed files with 18 additions and 1 deletions
				
			
		|  | @ -311,6 +311,8 @@ def read_until(self, match, timeout=None): | |||
|         s_args = s_reply | ||||
|         if timeout is not None: | ||||
|             s_args = s_args + (timeout,) | ||||
|             from time import time | ||||
|             time_start = time() | ||||
|         while not self.eof and select.select(*s_args) == s_reply: | ||||
|             i = max(0, len(self.cookedq)-n) | ||||
|             self.fill_rawq() | ||||
|  | @ -321,6 +323,11 @@ def read_until(self, match, timeout=None): | |||
|                 buf = self.cookedq[:i] | ||||
|                 self.cookedq = self.cookedq[i:] | ||||
|                 return buf | ||||
|             if timeout is not None: | ||||
|                 elapsed = time() - time_start | ||||
|                 if elapsed >= timeout: | ||||
|                     break | ||||
|                 s_args = s_reply + (timeout-elapsed,) | ||||
|         return self.read_very_lazy() | ||||
| 
 | ||||
|     def read_all(self): | ||||
|  | @ -601,6 +608,9 @@ def expect(self, list, timeout=None): | |||
|             if not hasattr(list[i], "search"): | ||||
|                 if not re: import re | ||||
|                 list[i] = re.compile(list[i]) | ||||
|         if timeout is not None: | ||||
|             from time import time | ||||
|             time_start = time() | ||||
|         while 1: | ||||
|             self.process_rawq() | ||||
|             for i in indices: | ||||
|  | @ -613,7 +623,11 @@ def expect(self, list, timeout=None): | |||
|             if self.eof: | ||||
|                 break | ||||
|             if timeout is not None: | ||||
|                 r, w, x = select.select([self.fileno()], [], [], timeout) | ||||
|                 elapsed = time() - time_start | ||||
|                 if elapsed >= timeout: | ||||
|                     break | ||||
|                 s_args = ([self.fileno()], [], [], timeout-elapsed) | ||||
|                 r, w, x = select.select(*s_args) | ||||
|                 if not r: | ||||
|                     break | ||||
|             self.fill_rawq() | ||||
|  |  | |||
|  | @ -22,6 +22,9 @@ Core and builtins | |||
| Library | ||||
| ------- | ||||
| 
 | ||||
| - Bug #822974: Honor timeout in telnetlib.{expect,read_until} | ||||
|   even if some data are received. | ||||
| 
 | ||||
| - Bug #1267547: Put proper recursive setup.py call into the | ||||
|   spec file generated by bdist_rpm. | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Martin v. Löwis
						Martin v. Löwis