The windows python.exe interpreter hangs processing large files.

gradha at iname.com gradha at iname.com
Mon Jul 23 15:21:06 EDT 2001


>> [gradha at iname.com]
>> Under Linux everything goes blazing fast, and since everything hangs
>> I don't know what to do or how to debug it, especially because Windows
>> is not my native work environment and don't master any tools there.
> Tim Peters <tim.one at home.com> wrote:
> Stick in print statements to determine *where* it hangs.

All output is written in sys.stdout, so I didn't redirect the output and
found out that the problem was inserting a big text file while scanning
it for recursive insertions. My script is some sort of html parser
and I use the re module to find <include-src=filename> tags, substituting
them with the pointed file instead.

> Then whittle it
> down to a minimal case.  The most frequent cause of Linux->Windows Python
> porting problems is neglecting to open binary files in binary mode.

A grep for open calls showed only "rt" modes. I solved the problem
avoiding the DOTALL option of the <include...> tag and rewritting my
brute force algorithm, which inserted whole files as a single string, to
use instead lists of lines, since the <include...> tag cannot be
split over more than a single line, and now the dos/windows version works
fast. If somebody wants to get the "bad" script along with some files to
parse, you can get it all from sourceforges cvs:

cvs -d:pserver:anonymous at cvs.alleg.sourceforge.net:/cvsroot/alleg/ co allegrowww

Just check out the version from "Sun Jul 22 09:21 2001 UTC". Alternatively
if somebody wants to check for this dos hangs, I can prepare a smaller
.zip with just the needed files to reproduce the problem, just mail me
privately. The hangs were so terrible that not even Ctrl+C interrupted
the script (and this ran on a PII 300 with plenty of ram...).

BTW, one user ran the script with Python 2.1 and got some warning messages
I don't get with 1.5 or 2.0:

c:\python21\python.exe webmake.py -o out -M src/*.html > dependency_info
webmake.py:0: SyntaxWarning: name 'expresion_include' is assigned to
before global declaration

My script is something like this:

#!/usr/bin/env python

import some_modules

expresion_multi = None
expresion_...
...

What's that and what can I do to avoid these warnings?

--
 Grzegorz Adam Hankiewicz   gradha at terra.es   http://gradha.infierno.org



More information about the Python-list mailing list