Mutex not thread safe? PEP-3108.

skip at pobox.com skip at pobox.com
Tue Sep 23 15:36:14 CEST 2008


>>>>> "Roy" == Roy Smith <roy at panix.com> writes:

    Roy> I'm perusing PEP-3108 and came upon this interesting statement
    Roy> (under the "Hardly used" section):

    Roy> mutex [...] Not thread-safe.

    Roy> How can a mutex, whose sole reason for existence is to mediate thread 
    Roy> safety, not be thread safe?

Because it is a mutex in name only.  Take a look at the code.  There is
nothing in there which actually locks the internal data structure against
simultaneous manipulation (a collections.deque instance in this case) from
multiple threads.

Skip



More information about the Python-list mailing list