Python 2.2 code continues running before list comprehension is completed?

Sion Arrowsmith siona at chiark.greenend.org.uk
Mon Jul 19 12:25:50 EDT 2004


Chris P. <chris.peressotti at utoronto.ca> wrote:
># Prior code opens telnet connection "tn" and logs in.
>tn.read_until('> ')
>tn.write('THE COMMAND IS HERE\n')
>dump = tn.read_very_eager()
>dump_lines = dump.split('\n')
>dump_info = [x for x in dump_lines if (VARIOUS CONDITIONS ON x)]
> [ ... ]
>So I tried putting (for x in dump_info: print x) right after I make
>the list comprehension and, when I run that, it shows that the list is
>incomplete... so it SEEMS like Python begins to create the list
>comprehension and then continues to execute commands before the list
>comprehension is finished!

Did you try putting a print in *before* the list comprehension
(for x in dump_lines: print x) to make sure you're getting all
the lines you think you're getting? Documentation says
read_very_eager() "Read[s] everything that's possible without
blocking in I/O" -- my first thought is that your client
running outside the debugger is reading faster than the server
can feed it data, it blocks part way through the execution of
the command, and read_very_eager() returns without the complete
output.

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list