<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clean(cls, pid):
 """Clean the specified pool, removing any closed connections or stale locks. :param str pid: The pool id to clean """

        with cls._lock:
            try:
                cls._ensure_pool_exists(pid)
            except KeyError:
                LOGGER.debug('Pool clean invoked against missing pool %s', pid)
                return
            cls._pools[pid].clean()
            cls._maybe_remove_pool(pid)