Synchronizing CGI processes?

Olivier Dagenais olivierS.dagenaisP at canadaA.comM
Thu Oct 12 17:20:22 EDT 2000


I am writing a client-server system in Python and the only free
Python-supporting internet server I can find supports Python as CGI scripts.
(Incidentally, if you know of any free hosting solutions that would allow me
to host a server written in Python with say, Medusa please say so!)  The
multiple independent process nature of CGI is the source of a very puzzling
synchronization problem:  how on earth can I guarantee synchronization
between two (or more) concurrent CGI sessions?  (I need to synchronize
writes to a simple, one-user database... I'm using "Gadfly" for the
curious...)

At this stage, I am only exploring ideas and haven't tried to implement any
of them, mostly because I would rather be sure of the atomicity of the
synchronization mechanisms than to discover that I was being lucky with my
2-user tests and it starts breaking six months down the road.

So far, I can only think of the following:
- use a file as a binary semaphore:  if it exists, return "busy" to the
client, if it doesn't exist, create it and be on your way.  Since I can not
assume what OS/webserver will be running my server, I don't know if I can
assume checking for a file and creating a file are atomic operations!

- use an environment variable as a binary semaphore.  The value of the
variable would allow me to synchronize operations, however (since I can not
assume what platform) I do not know if reading/writing an environment
variable is atomic and, even worse, if it can be persistent across
independent (sibling) processes!

It seems most cool synchronization solutions available in Python are only
good for threads.  :(

What are my options?  Can anybody clear up some of my assumptions/questions?
Like I said, I cannot assume what platform my server will be running, so it
could be Win95 with a simple webserver, NT4/W2K Server or any Unix/Linux!

Thanks for any help you can provide...

--
----------------------------------------------------------------------
Olivier A. Dagenais - Software Architect and Developer
"Someone called 'Type your name here' is impersonating me on the
internet and is posting exactly the same things I am posting!"







More information about the Python-list mailing list