Mutex not thread safe? PEP-3108.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roy Smith

    Mutex not thread safe? PEP-3108.

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

    mutex [...] Not thread-safe.

    How can a mutex, whose sole reason for existence is to mediate thread
    safety, not be thread safe?
  • skip@pobox.com

    #2
    Re: Mutex not thread safe? PEP-3108.

    >>>>"Roy" == Roy Smith <roy@panix.comw rites:

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

    Roymutex [...] Not thread-safe.

    RoyHow can a mutex, whose sole reason for existence is to mediate thread
    Roysafety, 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.deq ue instance in this case) from
    multiple threads.

    Skip

    Comment

    • Hrvoje Niksic

      #3
      Re: Mutex not thread safe? PEP-3108.

      Roy Smith <roy@panix.comw rites:
      I'm perusing PEP-3108 and came upon this interesting statement (under the
      "Hardly used" section):
      >
      mutex [...] Not thread-safe.
      >
      How can a mutex, whose sole reason for existence is to mediate thread
      safety, not be thread safe?
      "mutex" is a module designed for use with "sched", not for
      multithreading:

      """Mutual exclusion -- for use with module sched
      [...]
      Of course, no multi-threading is implied -- hence the funny interface
      for lock, where a function is called once the lock is aquired.
      """

      What is called a mutex in multithreading is known in Python as
      threading.Lock, and does work with threads.

      Comment

      Working...