shazow/urllib3 — pull request #204 by AudriusButkevicius (2013-07-18 17:00:29+00:00)
Title: Fix a race condition between pools.get and pools.set

We have parallel threads opening multiple connections to the same destination which lead to discovery of this.

Sequence of events:
T1: pools.get results a None
T2: pools.get results a None
T1: creates a new pool with key (x,y,z)
T2: creates a new pool with key (x,y,z)
T1: adds the pool to pools container under key (x,y,z)
T2: adds the pool to pools container under key (x,y,z) replacing the pool set by T1, and as a result applying dispose_func (closing the pool)
T1: returns the now closed pool for use
T1: calls pool.urlopen and throws an exception