[Idle-dev] [ idlefork-Bugs-677263 ] On W32 Can't Terminate Subprocess Not Doing IO

SourceForge.net noreply@sourceforge.net
Sat, 17 May 2003 08:05:15 -0700


Bugs item #677263, was opened at 2003-01-29 23:02
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=677263&group_id=9579

Category: None
Group: None
Status: Open
Resolution: Fixed
>Priority: 8
Submitted By: Bruce Sherwood (bsherwood)
Assigned to: Kurt B. Kaiser (kbk)
Summary: On W32 Can't Terminate Subprocess Not Doing IO

Initial Comment:
With 0.9a2 it is still the case that something is very 
wrong with the run environment for VPython programs, 
at least on Windows. I run the simplest program

from visual import *
sphere()

Next I kill the graphics display window (by clicking in the 
close box), then type in the shell "2+2". I get the 
following:

Traceback (most recent call last):
  File "C:\Python23\Lib\site-packages\idleforklib\rpc.py", 
line 187, in asynccall
    self.putmessage((seq, request))
  File "C:\Python23\Lib\site-packages\idleforklib\rpc.py", 
line 289, in putmessage
    n = self.sock.send(s)
  File "<string>", line 1, in send
error: (10054, 'Connection reset by peer')

I then try to kill the shell window and get a dialog box 
asking this:

"The program is still running; do you want to kill it?"

I say I want to kill it, the dialog box goes away, but 
nothing happens to the shell window. The only way I can 
kill Python is with the Windows task manager. Even 
independent of what may be special about a VPython 
program, shouldn't IDLE honor the request to kill?

I emphasize that with the original idlefork when one 
killed a VPython graphics window you were in a good 
state. Another possible hint at the source of the new 
problem is that with the original idlefork after F5 to run I 
could press F5 and the existing graphics window would 
be killed and I'd get a new spawned process. Now I 
seem to get two spawned processes in this situation.

http://vpython.org is a place to get the VPython stuff. I 
have no idea whether the problem is in some sense with 
VPython or with the new idlefork.


----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2003-05-17 10:05

Message:
Logged In: YES 
user_id=149084

I assume you can see this if you just restart the shell
without running any program.

CVS works fine on W2K. But if I replace run.py:56 os._exit(0) 
with sys.exit(0), then the subprocess hangs as you are
seeing.  That's why I used os._exit.  It appears 
something changed between Py2.2/2.3 and/or W2K/XP and
os._exit() on your box is acting like sys.exit() on my setup.

The way this works is when SockThread gets an EOF
due to the link being closed by the GUI, it sets the global
exit_requested and goes into a pass loop waiting for the
MainThread to terminate the whole process.  Every 10
bytecodes the MainThread gets control and checks 
exit_requested.  If True, it exits and is supposed to take
the SockThread with it since it's setDaemon.  But if the
MainThread exits without shutting down SockThread the
latter just spins, taking 100%, which is what you are 
seeing.  If I exit the SockThread instead of waiting, there
are other problems due to the Server objects disappearing
when then are still needed by MainThread and its various
socket threads (Thread-1, Thread-2 etc) not having
wrapped up communication.  That also causes hangs.

Try this, it works on my system: 
replace 
run.py:56 os._exit(0) 
with 
run.py:56 return.  

We'll let Python decide how to exit.

----------------------------------------------------------------------

Comment By: Bruce Sherwood (bsherwood)
Date: 2003-05-17 08:26

Message:
Logged In: YES 
user_id=34881

I do have run.py Rev 1.17. I got everything from CVS on 5/16. 
And I've checked by hand that I do have the addition 
of "except KeyboardInterrupt" in my copy of run.py. So that's 
not the explanation. What should I try now?

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-05-16 17:15

Message:
Logged In: YES 
user_id=149084

It's critical that you have run.py Rev 1.17
which was checked in 2003/05/14 18:15:40to fix this
problem.

The relevant line is run.py:65  except KeyboardInterrupt:
This line and the except clause following must be present.
Without this, the restart doesn't work because the
subprocess SockThreadstops servicing the socket while
the MainThread is trying to print an exception.

I was seeing the same before the fix.  Freddy's baaack?

----------------------------------------------------------------------

Comment By: Bruce Sherwood (bsherwood)
Date: 2003-05-16 16:44

Message:
Logged In: YES 
user_id=34881

On Windows XP I installed Python 2.3 and idlefork from CVS. 
I see massive problems. Minimal program "print 2+2" takes 
30 seconds or more after pressing F5 before I see the output 
(consuming 100% of the CPU all the while), and even after 
seeing the output the system monitor shows me consuming 
100% of the CPU. I then close both windows (source and 
output), and I'm left with two instances of python.exe which 
together or singly consume 100% of the CPU, and I have to 
kill them in the system monitor. Is there something I'm 
missing about installation? I have the idlefork package in 
C:\Python23\idle. I did run C:\Python23\python.exe setup.py 
install inside the idle directory in order to get the interrupt 
module compiled. I assume that I have all the pieces in that I 
did get output.

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-05-14 22:48

Message:
Logged In: YES 
user_id=149084

Please try current CVS and report any problems.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2003-04-01 00:51

Message:
Logged In: NO 

More on run/kill issues:

When I'm running my Tkinter app and editing the source code,
idlefork will sometimes hang when looking up a CallTip. The
IDLE windows won't redraw until I kill my app, and then the
editor is in a confused state. I can't evaluate expressions
in the shell or restart the program. I also can't restart
the shell. I'm using Win32. I think I'll get around to
investigating this more and typing up a bug report, but I
was hoping this little bit would help some. 

Randall Farmer, rfarmer@simons-rock.spam.edu

----------------------------------------------------------------------

Comment By: Kurt B. Kaiser (kbk)
Date: 2003-01-30 11:24

Message:
Logged In: YES 
user_id=149084

I changed the title, this isn't just a VPython issue. 
I can confirm what you are seeing, and I have some
ideas on how to fix it.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109579&aid=677263&group_id=9579