def connection(self):
self._condition.acquire()<EOL>try:<EOL><INDENT>if (self._maxconnections and self._connections >= self._maxconnections):<EOL><INDENT>raise TooManyConnections("<STR_LIT>" % (self._connections, self._maxconnections))<EOL><DEDENT>try: <EOL><INDENT>con = self._idle_cache.pop(<NUM_LIT:0>)<EOL><DEDENT>except IndexError: <EOL><INDENT>con = self.new_connection()<EOL><DEDENT>self._connections += <NUM_LIT:1><EOL><DEDENT>finally:<EOL><INDENT>self._condition.release()<EOL><DEDENT>return con<EOL>
get a cached connection from the pool