api.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:valohai-cli 作者: valohai 项目源码 文件源码
def _get_current_api_session():
    """
    Get an API session, either from the Click context cache, or a new one from the config.

    :return: API session
    :rtype: APISession
    """
    host, token = get_host_and_token()
    ctx = click.get_current_context(silent=True) or None
    cache_key = force_text('_api_session_%s_%s' % (host, token))
    session = (getattr(ctx, cache_key, None) if ctx else None)
    if not session:
        session = APISession(host, token)
        if ctx:
            setattr(ctx, cache_key, session)
    return session
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号