smacintyre/asyncmongo — pull request #2 by philwhln (2011-12-07 00:06:22+00:00)
Title: fix bug where __try_node incorrectly returns connection object to the pool, but carries on using it

Hi smacintyre,

I found another edge case. Not as easy to replicate.

In __try_node(), if the underlining socket connection is __alive then the socket connection is closed and the connection object is returned to the pool, although __try_node goes on to make a new socket connection with this connection object. So hits another "connection in use" when something else pulls it out of the pool.

To fix this, I changed self.close() to self._close(), since _close() just closes the socket connection and does not return the connection object to the pool.

Cheers,
Phil