[Tutor] static variables - lock/semaphore

Alan Gauld alan.gauld at freenet.co.uk
Sun Jul 2 16:24:41 CEST 2006


> if we compare rowlevel locking and global variables
> which scales and is better

>>Alan Gauld <alan.gauld at freenet.co.uk> wrote: 
>>> is there a way to use some sort of semaphore or lock
>>> so that it is not accessed simultaneously
> >
> > There are ways of doing this in Python but if you are using 
> > a relational database for the data its usually easier to 
> > apply row level locking at the database level.

Row level locking in the database is far more scaleable than 
global variables. They are more reliable, only apply during the 
actual database writes and cannot be circiumvented by 
programs forking or spawning clones of themselves or by 
other applications accessing the same data.

Almost all very high volume applicatoons use database locking
- everything from banking systems to airtline bookings etc.
Coupled to the transaction management features of a database 
(Commit, rollback etc) you can build very powerful, very scaleable 
databases capable of handling 100s of transactions per second.

Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list