Dangling threads are reported when run test_socket tests which raise SkipTest in setUp() in refleak mode.
$ ./python -m test -R 3:3 test_socket -m testBCM
0:00:00 load avg: 2.53 Run tests sequentially
0:00:00 load avg: 2.53 [1/1] test_socket
beginning 6 repetitions
123456
.Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 1)
Warning -- Dangling thread: <_MainThread(MainThread, started 139675429708416)>
.Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 1)
Warning -- Dangling thread: <_MainThread(MainThread, started 139675429708416)>
.Warning -- threading_cleanup() failed to cleanup 1 threads (count: 1, dangling: 1)
Warning -- Dangling thread: <_MainThread(MainThread, started 139675429708416)>
...
test_socket failed (env changed)
== Tests result: SUCCESS ==
1 test altered the execution environment:
test_socket
Total duration: 655 ms
Tests result: SUCCESS
It happens because tearDown() is not called if setUp() raises any exception (including SkipTest). If we want to execute some cleanup code it should be registered with addCleanup().