import ostime def child(pipeout)zzz while truetime sleep(zzzmsg ('spam % dzzzencode(os write(pipeoutmsgzzz (zzz+ make parent wait pipes are binary bytes send to parent goto after def parent()pipeinpipeout os pipe(make -ended pipe if os fork(= copy this process child(pipeoutin copyrun child elsein parentlisten to pipe while trueline os read(pipein blocks until data sent print('parent % got [%sat % (os getpid()linetime time())parent(if you run this program on linuxcygwinor another unix-like platform (pipe is available on standard windows pythonbut fork is not)the parent process waits for the child to send data on the pipe each time it calls os read it' almost as if the child and parent act as client and server here--the parent starts the child and waits for it to initiate communication to simulate differing task durationsthe child keeps the parent waiting one second longer between messages with time sleep callsuntil the delay has reached four seconds when the zzz delay counter hits it rolls back down to and starts again[ :\pp \system\processes]python pipe py parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at parent got [ 'spam 'at #we will clarify the notions of "clientand "serverin the internet programming part of this book therewe'll communicate with sockets (which we'll see later in this are roughly like bidirectional pipes for programs running both across networks and on the same machine)but the overall conversation model is similar named pipes (fifos)described aheadare also better match to the client/server model because they can be accessed by arbitraryunrelated processes (no forks are requiredbut as we'll seethe socket port model is generally used by most internet scripting protocols--emailfor instanceis mostly just formatted strings shipped over sockets between programs on standard port numbers reserved for the email protocol interprocess communication