Threading lock python. This can lead to race conditions and inconsistent data states...