Syncronizing CGI Scripts
Changjune Kim
juneaftn at REMOVETHIShanmail.net
Mon Aug 26 11:15:19 EDT 2002
"Thomas Guettler" <pan-newsreader at thomas-guettler.de> wrote in message
news:pan.2002.08.26.08.44.31.203979.727 at thomas-guettler.de...
> Hi!
>
> How can I syncronize CGI scripts?
>
> A data-file containing pickled data should be updated
>
> thomas
You need a locking scheme such as lock file or file locking.
If you use lock files there is an easy platform-independent(at least on
win32 and linux) way:
fd=os.open('dbfile.lck',os.O_WRONLY|os.O_CREAT|os.O_EXCL)
or you could use atomic "create a directory" command.
If you want to use file locking, you can use fcntl on *nix and use win32
specific api calls on win32. Or you may have a look at ZODB winlock.c file.
As somebody mentioned, Sheila King implemented a win32/*nix lock module.
Another possibility is using socket communication with a server to
synchronize db access.
In addition to these locking schemes, you need update scheme. When two
processes have each dbhash(or shelve) file connection, one updates(such as
adding a new key) and the other's isn't updated automatically. You have to
close and reopen the file each time you read/write.
Of course, you can use a RDBMS such as mysql, or embeded DBMS such as
sqlite, gadfly, zodb(with zeo), or bsddb3, which comes with locking ...
More information about the Python-list
mailing list