Determining EOF character

Daniel Klein danielk at
Tue Feb 20 15:12:30 CET 2001

On Mon, 19 Feb 2001 20:47:22 -0600, "Chris Gonnerman" <chris.gonnerman at>

>So why does closing the pipe to signal EOF not work?  I've written a great many programs
>based on that.  The writer closes the pipe and terminates, and the reader gets EOF and
>continues operation.  What am I missing here?

John Baxter is correct, but to explain a bit further, the server process could
have an entire environment set up; closing the pipe would lose that
environment. If I closed the pipe it would be like initializing the same
objects for each iteration of a loop, ie

while 1:
	foo = Bar()
	dead = Parrot()
	spam = Eggs()
	# rest of processing using 'foo', 'dead', 'spam'

rather than

foo = Bar()
dead = Parrot()
spam = Eggs()
while 1:
	# etc.

To be honest, the whole purpose for this was to catch and report unexpected
server errors that could not be controlled by the server process. In addition,
I had thought to be able to use the 'readlines()' method to recv more than one
line at a time. For now, since I can't do this, I have coded around the problem
by using only 'readline()' and ensuring that if the server process sends more
than one line of data to the client, it will gracefully (rather than violently)
shut itself down rather than just 'hang' waiting for an EOF. I do this by
always sending an 'expected' reply to the client; if the client does not see
this, it takes the aforementioned action.

I think you can put this thread to rest at this point. Thanks for all your
input, this has been a great learning experience for me. :^)

Daniel Klein
Portland OR USA

More information about the Python-list mailing list