Reputation: 983
Python lock seems to be the most primitive synchronization mechanism used by other synchronization variables.
I wanted to know how a python lock works? Where can I check the source code and implementation of the lock? Also, if multiple threads are waiting on the lock, which thread is woken up during a release?
Upvotes: 1
Views: 851
Reputation: 1762
It is NOT a simple question because of the existence of GIL, have a look at this blog.
Usually, people use CPython implement. The source code of thread module is here.
Any thread in waiting state has the possibility to be woken up. So you might treat it as a random pickup.
Upvotes: 3