Because of multithreading semantics, this is not reliable.

Christophe chris.cavalaria at
Thu May 4 15:26:08 CEST 2006

Olaf Meding a écrit :
>>return result   before that line, some other thread added a value !
> Sure, but that is the nature of using threads and a mutex.  I hope you are
> you not saying that every function that uses a mutex should have a comment
> saying this is not "reliable"?

That function can return a value that was already obsolete even before 
it finished executing. And so special care should be taken by the user 
so that he can either cope with that or make sure that it doesn't happens.

As was said, it's the same reason the user should not do a if 
fileExists() followed by a openFile. Same reason that there is a warning 
in the "os.access" manual

More information about the Python-list mailing list