Syncronizing CGI Scripts

Changjune Kim juneaftn at
Mon Aug 26 17:15:19 CEST 2002

"Thomas Guettler" <pan-newsreader at> wrote in message
news:pan.2002. at
> 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:'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