Is double-checked locking thread-safe in Python? Is double-checked locking thread-safe in Python? multithreading multithreading

Is double-checked locking thread-safe in Python?


Have a look at PEP 583 - Concurrency memory model for Python, which was withdrawn.

I guess the reason it was withdrawn (though I can't find enough information on that) is since there are different implementations of Python, and it's difficult to enforce a standard like this on every one of them.

Conclusion: this code might be safe when using CPython implementation on a single processor, or it might be safe to use it in general using Jython implementation, but there's no guarantee.