python thread safety test using locks