Threads and racing conditions

Flavio Preto flavio.preto at gmail.com
Wed Aug 22 00:26:27 EDT 2007


Hi,

I have a doubt. Supose that i have the minimun class below:

class db:
    def __init__(self):
        self.db = {}
    def read(self, key):
        return self.db[key]
    def write(self, key, value):
        self.db[key] = value


and an object of this class is shared among some threads. Is it possible
that in a read, the method return a value that is not an old or a new value?
In other words, is it possible that a 'read' return (due to a 'write' at the
same time by another thread) an invalid value that was never supposed to be
there?

Thanks,
Flavio Preto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070822/afed785e/attachment.html>


More information about the Python-list mailing list