[2.7] bpo-30727: Fix a race condition in test_threading. (GH-2334). (#2353)

(cherry picked from commit 32cb968a2edd482891c33b6f2ebae10f1d305424)
1 file changed