Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Difference between mutex.mutex and threading.Lock

Reply
Thread Tools

Difference between mutex.mutex and threading.Lock

 
 
sven
Guest
Posts: n/a
 
      12-04-2009
Hi,

what is the difference between mutex.mutex and threading.Lock?
Neither the documentation nor a Google search gave me any clue.

Another issue: The documentation of mutex in version 2.6.4 says:

"Deprecated since version The: mutex module has been removed in Python
3.0."

Maybe it should also say what to use instead (probably
threading.Lock?). Also the "version The" part seems a bit strange.

Greetings,
Sven
 
Reply With Quote
 
 
 
 
zeph
Guest
Posts: n/a
 
      12-04-2009
The mutex class (and module) should not be used, since it is, as you
said, deprecated for 3.0. Like the docs say, it "does not require (or
imply) threading or multi-tasking, though it could be useful for those
purposes." The mutex class' lock() method takes a function and args
and if the mutex is unlocked, calls the function with args
immediately, or if locked, adds to a queue and waits for it to be
unlocked

The threading.Lock object is a lock shared between threads. For
example, if you have two threads (thread1 and thread2) and thread1
does lock.acquire() and thread 2 calls lock.acquire(), thread2 will
block until thread1 calls lock.release(), then thread2 will get a
chance to run its critical code section, then call lock.release().

- zeph
 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      12-04-2009
In article
<(E-Mail Removed)>,
zeph <(E-Mail Removed)> wrote:

> The mutex class (and module) should not be used, since it is, as you
> said, deprecated for 3.0. Like the docs say, it "does not require (or
> imply) threading or multi-tasking, though it could be useful for those
> purposes."


Over the years, many things about Python have surprised, amused, and on
occasion confused, me. I must admit, having a mutex which isn't
thread-safe is pretty high up on the list of "does not fit my brain" items

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 04-15-2011 04:00 AM
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 01-06-2011 05:00 PM
difference between between these "char"s arnuld C++ 33 03-05-2007 03:11 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static' Santa C Programming 1 07-17-2003 02:10 PM



Advertisments