[Bug #1552726] Avoid unnecessary polling at the interpreter prompt when certain versions of readline are being used

This commit is contained in:
Andrew M. Kuchling 2007-01-22 16:10:27 +00:00
parent e69747c630
commit b8c6e1f33f
2 changed files with 9 additions and 1 deletions

View File

@ -139,6 +139,8 @@ Extension Modules
- Modifying an empty deque during iteration now raises RuntimeError - Modifying an empty deque during iteration now raises RuntimeError
instead of StopIteration. instead of StopIteration.
- Bug #1552726: fix polling at the interpreter prompt when certain
versions of the readline library are in use.
Library Library
------- -------

View File

@ -768,10 +768,16 @@ readline_until_enter_or_signal(char *prompt, int *signal)
while (!has_input) while (!has_input)
{ struct timeval timeout = {0, 100000}; /* 0.1 seconds */ { 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); FD_SET(fileno(rl_instream), &selectset);
/* select resets selectset if no input was available */ /* select resets selectset if no input was available */
has_input = select(fileno(rl_instream) + 1, &selectset, has_input = select(fileno(rl_instream) + 1, &selectset,
NULL, NULL, &timeout); NULL, NULL, timeoutp);
if(PyOS_InputHook) PyOS_InputHook(); if(PyOS_InputHook) PyOS_InputHook();
} }