def close(self):
if self._closed:<EOL><INDENT>return<EOL><DEDENT>try:<EOL><INDENT>with self.lock:<EOL><INDENT>if not self._closed:<EOL><INDENT>self._closed = True<EOL>for address in list(self.connections):<EOL><INDENT>self.remove(address)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except TypeError as e:<EOL><INDENT>pass<EOL><DEDENT>
Close all connections and empty the pool.
        This method is thread safe.