FIFO problems

Gary Herron gherron at islandtraining.com
Thu Sep 11 07:38:38 CEST 2003


The most generic method of doing interprocess communication (with
process on the same or different machine) is to use sockets.  See
Python's socket module.  There are lots of other ways -- pipes (see
the os.popen family) and shared memory, but you'll be able to find
many examples and much documentation for sockets.  Reading and writing
straight files (if that is really what you are doing) is probably not
going to work well.

Gary Herron


On Wednesday 10 September 2003 10:23 pm, Tobias Pfeiffer wrote:
> Hi!
>
> I want to write a "client-server-application" (only running on the same
> machine) or actually I've already begun with and have problems with the
> interprocess communication. The server, when started, opens a FIFO and
> opens it with open(infifo, 'r'). Then I check the content of the file
> with
>
> while 1:
>     	line = serverIn.readline()[:-1]
>     	if line == "bla":
>     	    	do this
>     	else:
>     	    	print line
>
> So at the beginning everything works fine. I can start the client prog
> and they will talk and understand to each other. The same if I connect
> with three or more clients simultaneously (?). If one of these clients
> exists, no problem. But when the last process exists and closes the
> FIFO-file which was opened by os.open(infifo, os.O_WRONLY), the server
> begins to print an empty string everytime it goes through the loop,
> means it won't wait for a complete line to appear before continuing.
> Why?
> Then I modified the thing above to:
>
> while 1:
>     	line = serverIn.readline()[:-1]
>     	if line == "bla":
>     	    	do this
>     	elif line == "":
>     	    	open(infifo, 'r')
>     	    	print "help!!!"
>     	else:
>     	    	print line
>
> So in contrast to what I thought, there was not a bunch of "help!!!"
> lines printed, but nothing. When I tried then to connect again, there
> was a single "help!!!" and then the correct message for the client
> having connected.
>
> So, anyone any idea how I can fix this. I just want the server to
> continue line-by-line-reading...
>
> Bye
> Tobias







More information about the Python-list mailing list