Profiler.py 文件源码

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

项目:py-IoticAgent 作者: Iotic-Labs 项目源码 文件源码
def profiled_thread(func):
    """decorator to profile a thread or function. Profiling output will be written to
    'agent_profile_<process_id>.<thread_id_>.<thread_name>.log'"""

    def wrapper(*args, **kwargs):
        profile = Profile()
        profile.enable()
        try:
            func(*args, **kwargs)
        finally:
            profile.disable()
        try:
            thread = current_thread()
            profile.dump_stats('profile_%s.%s.%s.log' % (getpid(), thread.name, thread.ident))
        except:
            logger.exception('Failed to dump stats')

    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号