Sunday, 15 June 2014

python - Is RLock a sensible default over Lock? -


Threading module in Python provides two types of locks: a common lock and a recantent lock I think if I lock it Should I always like RLock on lock; Mainly to prevent deadlock situations.

In addition, I get two points, when lock on an RLock is preferred:

  • There is a more complex internal structure in RLock and therefore poor performance Could.
  • Due to some reason, I want to restart a thread through lock.

Is my argument correct? Can you tell other aspects?

two points:

  • Officially Python version (2.4, 2.5 to 3.1) is much slower than a lock lock, because locks in C and RLox in Python apply (this will change to 3.2)
  • A < / Li>

Bottom line, I can release it from any thread (not necessarily the thread that receives it), while an RLock should be released from the same thread, D only a Suggests using Arelk if it coincides with the words that you are looking for, otherwise default glued locks.


No comments:

Post a Comment