Title: Minimal cleanup of
Type: Stage:
Components: IDLE Versions:
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: kbk Nosy List: kbk, mdehoon
Priority: normal Keywords: patch

Created on 2005-04-26 10:50 by mdehoon, last changed 2005-05-05 23:30 by kbk. This issue is now closed.

File name Uploaded Description Edit mdehoon, 2005-04-26 10:50 Patch to in Lib/idlelib
Messages (2)
msg48261 - (view) Author: Michiel de Hoon (mdehoon) * Date: 2005-04-26 10:50
In the main function in in Lib/idlelib, we have

    seq, request = rpc.request_queue.get(0)
except Queue.Empty:

The get method of rpc.request_queue already has the
option of a timeout, so we can use that instead of
inlining time.sleep:

    seq, request = rpc.request_queue.get(block=True, 
except Queue.Empty:

resulting in a (small) simplication of the code. The
patch was tested on Windows, Linux, and Mac OS X.

In case you are wondering why I care about this:
My real interest is in PyOS_InputHook, a pointer to a
function which is called ten times per second when
Python is idle (e.g., waiting for user input).
Currently, calls to PyOS_InputHook are missing in some
cases where Python goes idle. I am going through the
code to fix this. Now, since both the original code in and rpc.request_queue.get cause Python to go
idle (by calling the sleep function), it means that I
would have to fix both cases. By making use of the
existing code in rpc.request_queue.get, I need to fix
this routine only (which I will do in a later patch),
and avoids having calls to PyOS_InputHook all over the
msg48262 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2005-05-05 23:30
Logged In: YES 
user_id=149084 rev 1.32
Date User Action Args
2005-04-26 10:50:29mdehooncreate