The previous approach was not addressing the root cause.
The root cause is still a bit unclear as it involved python gc'ing a socket or not before
leaving pycurl polling it...
Anyway, this fix makes no hazardous assumption about the http protocol ;)
It explicitly shuts down the socket when the thread handling a http[s] connection is about
to finish. In our case, when the connection is closed by the server after sending a 404 error.
That may reduce the number of tests leaking threads, but it doesn't address all cases
(and it's hard to measure precisely anyway until we fix them all).
The previous approach was not addressing the root cause.
The root cause is still a bit unclear as it involved python gc'ing a socket or not before
leaving pycurl polling it...
Anyway, this fix makes no hazardous assumption about the http protocol ;)
It explicitly shuts down the socket when the thread handling a http[s] connection is about
to finish. In our case, when the connection is closed by the server after sending a 404 error.
That may reduce the number of tests leaking threads, but it doesn't address all cases
(and it's hard to measure precisely anyway until we fix them all).