file open verification

Chris Liechti cliechti at gmx.net
Fri Sep 27 13:30:38 EDT 2002


python473 at yahoo.com (John Howard) wrote in 
news:9eabe547.0209270710.17ca112d at posting.google.com:

> Two questions - somewhat related:
> 
> Situation - I have several files on an apache server that are being
> accessed by
> python programs that are receiving data from html forms.
> 
> q1: How can the status of a file be checked?  If two forms have been
> submitted
> and the data is being added to a common file, how do I know that data
> from both forms are being written correctly to the common file?

don't ever write simultaneous from two processes to one file. your choices 
are:
- use "locks", so that only writes at a time
- one server writes the file, logs are directed to that server (like syslog  
on linux)
- use a database
- ...
all these options ensure that one writes after the other. avoiding problems 
is better than fixing.

> q2: Related to above - really more of a cgi question - does the apache
> server keep all these file accesses separate some way?

don't know apache. if you manage to limit it on one thread, only one can 
access the file. but iin that case the performace of the server is poooooor 
;-)

chris
-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list