> i have a program that is run on a website, and as it > is run from a website, it can be called more than once > and hence could end up corrupting db/data > 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. > the problem is it can be done with static variables in > C but how is it done in python It could be done with a global variable in Python in the same way but there are other solutions based around threads which have explicit locks etc. For a web application using Python threads would probably be a good bet. But you may find the whole problem simplified by adopting a web framework such as TurboGears which will take care of a lot of these kinds of issues for you - but with a bit of a learning curve. But if you have several web apps to build I'd seriously consider this route. Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor