Can you race condition in Python while there is a GIL?
问题 My understanding is that due to the Global Interpreter Lock in cPython, only one thread can ever be executed at any one time. Does this or does this not automatically protected against race conditions, such as the lost update problem? Just to be clear, I am asking from a theoretical perspective. I would never write threaded code without synchronization. 回答1: Due to the GIL, there is only ever one thread per process active to execute Python bytecode; the bytecode evaluation loop is protected