<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(cls, pid, connection):
 """Add a new connection and session to a pool. :param str pid: The pool id :type connection: psycopg2.extensions.connection :param connection: The connection to add to the pool """

        with cls._lock:
            cls._ensure_pool_exists(pid)
            cls._pools[pid].add(connection)