From kbk at shore.net Sun Mar 19 08:08:08 2006 From: kbk at shore.net (Kurt B. Kaiser) Date: Sun, 19 Mar 2006 02:08:08 -0500 Subject: [Idle-dev] strange bug In-Reply-To: <43FD2A29.8000800@ncsu.edu> (Bruce Sherwood's message of "Wed, 22 Feb 2006 22:21:13 -0500") References: <43FD2A29.8000800@ncsu.edu> Message-ID: <874q1ukj3b.fsf@hydra.bayview.thirdcreek.com> Bruce Sherwood writes: Sorry it took so long for me to get to this. > This year we have about 1600 engineering and science students at > NCSU writing VPython programs as the computational physics component > of the introductory calculus-based physics course. Until this > semester we (of course) had almost zero losses of editing work. We > have auto-save enabled, so F5 saves the student's work before > running the program. It shouldn't make any difference whether autosave is enabled, except possibly that the students might be closing the VPython graphics window more quickly when using it. > In December the computer environment on the Windows machines in the > physics labs was revised, possibly not entirely competently. And now > for the first time many students are losing their work, which is a > nightmare. Press F5, see the VPython 3d graphics window, and (very > occasionally, not reproducibly) the program freezes. Student goes to > monitor and kills the process and also the IDLE-associated processes > (edit window and shell window). Student now finds that the source > file exists but is zero-length and empty. The code which saves the file is single threaded, and the file is saved before the subprocess is initialized. ScriptBinding.run_module_event() calls ScriptBinding.getfilename(), which (if the Edit window hasn't been saved) calls IOBinding.save(). The latter calls IOBinding.writefile(), which opens, writes, and closes the file (within a try/except) before returning. If there is an IOError, a dialog is raised to notify the user. There's not a lot of C code to implementing the file open/write/close operations, and I reviewed it. It all looks pretty solid, and hasn't changed for quite awhile. Opening the file truncates it to zero length. The contents of the Text object are written to the file, then the file is closed. As I said, from a Python point of view all of that happens before the subprocess is restarted. When I first read your email, I figured maybe IDLE wasn't closing the file after writing it. But that's not the case, it is closed. > If the student just kills the graphics windows (using the Windows > monitor), IDLE runs and all is well, but it has taken awhile to > learn this procedure. Of course, that's one of the main benefits of splitting up the GUI and the subprocess. You can kill off the errant subprocess without losing your state. > A possible reason for the graphics window freezing up is that the > December reworking of the machine environment left us with poor > graphics drivers with respect to OpenGL, but who knows. When the subprocess hangs or crashes because of drivers (or an error in VPython), nothing can be done to interrupt/restart the subprocess because the socket control thread isn't getting a chance to run. > The freeze seems to happen more often if there are many processes > and/or windows active, or at least that's the folklore (the machines > only have 256 MB of memory). You might be running out of memory, and that could affect the file writing to the AFS. It rather sounds like Windows or the AFS interface is buffering the file sync/close somehow, and when the IDLE GUI is terminated the buffer is dropped. It must take the students 20 seconds to kill the VPython graphics window. The file should have been written and closed long before. > To add to the complexity, students normally connect to their > campus-wide AFS account which shows up as an extra disk drive on > Windows, and they edit the AFS source file in IDLE. Have you ever seen the problem when not using the AFS? > Does this ring any bells? I'm afraid it doesn't. The code in that part of both IDLE and Python has been stable for some time. Data loss is the worst kind of error, and quite discouraging to students. I'd certainly like to see this fixed. One possibility would be to add a f.flush() call before f.close(). It's not unusual for an OS to delay writing out a buffer. It seems unusual to me to destroy an unwritten buffer when the process that wrote to it is destroyed, but it's possible. Try adding one line of code in IOBinding.py:IOBinding.writefile() : f = open(filename, "wb") f.write(chars) f.flush() <---------!! f.close() I'm going to try to add that to the upcoming 2.4.3. It can't hurt. -- KBK From pvenkatesa at osi-tech.com Wed Mar 22 16:11:55 2006 From: pvenkatesa at osi-tech.com (Pragathi Venkatesa) Date: Wed, 22 Mar 2006 20:41:55 +0530 Subject: [Idle-dev] Run Script option now shown Message-ID: <200603221514.k2MFEQB21392@osi-tech.com> Hi, I am very new to programming field. Since I am using this Python for the first time, I am little bit confused. I see no command like 'Run Script' in the Edit menu. Should I change some settings? Please help. Thanks, Pragathi Project Associate OSI Technologies Office Address: Plot # 17, 1st Floor, Lakshmi Towers - B, Nagarjuna Hills, Hyderabad 500 082. Andhra Pradesh, India Work: +91 40 30603011 / 12 / 13 pvenkatesa at osi-tech.com ____________________________________________________________________________ _______________________ For Business Support Services, contact OSI Tech Support United States: Phone: 1.949.340.3715 / 1.714.373.3005 ext: 327 India Phone: 91.040.233.90.080 Please Visit http://www.osi-tech.com Disclaimer: The information contained in this e-mail message and any attachments is confidential information intended only for the use of the individual or entities named above. If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail at the originating address. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/idle-dev/attachments/20060322/80ba5baa/attachment.html From dooms at info.ucl.ac.be Thu Mar 23 15:52:10 2006 From: dooms at info.ucl.ac.be (=?ISO-8859-1?Q?Gr=E9goire_Dooms?=) Date: Thu, 23 Mar 2006 15:52:10 +0100 Subject: [Idle-dev] Run Script option now shown In-Reply-To: <200603221514.k2MFEQB21392@osi-tech.com> References: <200603221514.k2MFEQB21392@osi-tech.com> Message-ID: <4422B61A.2020201@info.ucl.ac.be> Pragathi Venkatesa wrote: > Hi, > > I am very new to programming field. > > Since I am using this Python for the first time, I am little bit confused. > > I see no command like 'Run Script' in the Edit menu. Should I change some > settings? > If you are in the Python shell, the statements you type are executed instantly. If you use the File->New Window option, you will be able to write a script and you should have a run menu with a run module entry (F5). For introductory python questions you should go to the python-tutor mailing list. http://mail.python.org/mailman/listinfo/tutor HTH, -- Gr?goire Dooms