_cpu_utils.py 文件源码

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

项目:perf 作者: vstinner 项目源码 文件源码
def get_logical_cpu_count():
    if psutil is not None:
        # Number of logical CPUs
        cpu_count = psutil.cpu_count()
    elif hasattr(os, 'cpu_count'):
        # Python 3.4
        cpu_count = os.cpu_count()
    else:
        cpu_count = None
        try:
            import multiprocessing
        except ImportError:
            pass
        else:
            try:
                cpu_count = multiprocessing.cpu_count()
            except NotImplementedError:
                pass

    if cpu_count is not None and cpu_count < 1:
        return None

    return cpu_count
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号