From: Andrew M. Kuchling Date: Mon, 22 Jan 2007 16:10:27 +0000 (+0000) Subject: [Bug #1552726] Avoid unnecessary polling at the interpreter prompt when certain versi... X-Git-Tag: v2.5.1c1~150 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8c6e1f33f9364b47af306791b44dba4109afd82;p=python [Bug #1552726] Avoid unnecessary polling at the interpreter prompt when certain versions of readline are being used --- diff --git a/Misc/NEWS b/Misc/NEWS index eeab829d0f..9876af9c93 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -139,6 +139,8 @@ Extension Modules - Modifying an empty deque during iteration now raises RuntimeError instead of StopIteration. +- Bug #1552726: fix polling at the interpreter prompt when certain + versions of the readline library are in use. Library ------- diff --git a/Modules/readline.c b/Modules/readline.c index 92f2d1f15f..853874be25 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(); }