Python thread locking class variable initialisation confusion