[Python-checkins] r51815 - python/trunk/Modules/readline.c

andrew.kuchling python-checkins at python.org
Thu Sep 7 16:00:17 CEST 2006


Author: andrew.kuchling
Date: Thu Sep  7 15:59:38 2006
New Revision: 51815

Modified:
   python/trunk/Modules/readline.c
Log:
[Bug #1552726] Avoid repeatedly polling in interactive mode -- only put a timeout on the select()
if an input hook has been defined.  Patch by Richard Boulton.

This select() code is only executed with readline 2.1, or if 
READLINE_CALLBACKS is defined.

Backport candidate for 2.5, 2.4, probably earlier versions too.


Modified: python/trunk/Modules/readline.c
==============================================================================
--- python/trunk/Modules/readline.c	(original)
+++ python/trunk/Modules/readline.c	Thu Sep  7 15:59:38 2006
@@ -768,10 +768,16 @@
 
 		while (!has_input)
 		{	struct timeval timeout = {0, 100000}; /* 0.1 seconds */
+
+			/* [Bug #1552726] Only limit the pause if an input hook has been 
+			   defined.  */
+		 	struct timeval *timeoutp = NULL;
+			if (PyOS_InputHook) 
+				timeoutp = &timeout;
 			FD_SET(fileno(rl_instream), &selectset);
 			/* select resets selectset if no input was available */
 			has_input = select(fileno(rl_instream) + 1, &selectset,
-					   NULL, NULL, &timeout);
+					   NULL, NULL, timeoutp);
 			if(PyOS_InputHook) PyOS_InputHook();
 		}
 


More information about the Python-checkins mailing list