Emile van Sebille wrote:
Lie Ryan wrote:

In a much simpler situation, even a communicating from a plain file
could be enough. In the daemon's program folder, there'll be two files:
input and output. You write to input to instruct the server and read the
response from output. This model is in respect to Unix's philosophy:
"make program to handle text streams, because it's the universal
interface".


I've done this and it works well... one thing to watch out for though is snagging a file before it's completely written. Setting up a semaphore or pausing to allow the file write to complete once seeing the file fixes it adequately.


If instead of an input/output file you use a directory this is easily solved. You write your request to a uniquely named file (with .in extension) and you read the response out of an equally named file with a .out extension. The server polls the directory for new .in files and processes them in order of creation date (you can even include a priorities scheme coded in the extension (e.g. .in1 to .in9 for the different priorities).



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to