Solved: Python 2.2 code continues running before list comprehension is completed?
chris.peressotti at utoronto.ca
Tue Jul 20 17:08:44 CEST 2004
Hey. Just thought I'd give an update that I figured out how to make
my script work. The original code was:
> 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)]
Sion had suggested that the client is reading faster than the server,
and I might want to try tn.read_all() instead of tn.read_very_eager().
That actually didn't work for me - read_all() documentation says:
"Read all data until EOF; block until connection closed" and that's a
problem... it makes my system hang, I'm guessing because the command I
send doesn't close the connection directly after it runs.
SO, I should have just looked to myself for inspriation: replacing the
tn.read_very_eager() with tn.read_until('> ') ensures that everything
up to the next command prompt is read in.
More information about the Python-list