'Close and delete timed-out connection.'

def _clean_sessions(self):

    to_del = []
    for (session_id, session) in self.sessions.items():
        if session.data_lock.acquire(False):
            if (((not session.is_finished()) and (not session.timeout())) or session.is_finished()):
                if (not session.is_finished()):
                    logging.warn(('Sync    session    %s    timed    out    and    will    be    closed    and    deleted.' % session.hosts))
                session.close()
                to_del.append(session_id)
            session.data_lock.release()
    for td in to_del:
        del self.sessions[td]
