def _get_session(team, timeout=None):
    """
    Creates a session or returns an existing session.
    """
    global _sessions            # pylint:disable=C0103
    session = _sessions.get(team)
    if session is None:
        auth = _create_auth(team, timeout)
        _sessions[team] = session = _create_session(team, auth)

    assert session is not None

    return session
Creates a session or returns an existing session.