diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-09-07 13:59:38 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-09-07 13:59:38 (GMT) |
commit | 62e475b84f0cf3343fbd15810678b3c6f728aa9f (patch) | |
tree | 6d2303740dcc5d00f08301d9b180a6033f3a0fa9 | |
parent | 95b0478c0750d71d4b709c6e5f0955d214d2bf85 (diff) | |
download | cpython-62e475b84f0cf3343fbd15810678b3c6f728aa9f.zip cpython-62e475b84f0cf3343fbd15810678b3c6f728aa9f.tar.gz cpython-62e475b84f0cf3343fbd15810678b3c6f728aa9f.tar.bz2 |
[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.
-rw-r--r-- | Modules/readline.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/readline.c b/Modules/readline.c index 92f2d1f..853874b 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -768,10 +768,16 @@ readline_until_enter_or_signal(char *prompt, int *signal) 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(); } |