zoukankan      html  css  js  c++  java
  • Openstack nova协程导致远程DEBUG失败解决方法

    在调试Nova代码时,代码中加入了远程pydevd断点,如下:

        def schedule_and_build_instances(self, context, build_requests,
                                         request_specs, image,
                                         admin_password, injected_files,
                                         requested_networks, block_device_mapping,
                                         tags=None):
            # Add all the UUIDs for the instances
            import pydevd
            pydevd.settrace('localhost', port=12345, stdoutToServer=True, stderrToServer=True)
            print "start schedule_and_build_instances"
            instance_uuids = [spec.instance_uuid for spec in request_specs]
            try:
                host_lists = self._schedule_instances(context, request_specs[0],
                        instance_uuids, return_alternates=True)

    在pycharm中显示DEBUG连接成功,但无法进入断点,这种情况是由于nova中使用了协程,协程(https://www.cnblogs.com/gorlf/p/4246659.html)得在代码入口处就使用,出现在/nova/cmd/__init__.py中,如下:

    import eventlet
    
    from nova import debugger
    
    if debugger.enabled():
        # turn off thread patching to enable the remote debugger
        eventlet.monkey_patch(os=False, thread=False)
    else:
        eventlet.monkey_patch(os=False)

    解决协程导致调试问题,将上述代码修改如下:

    import eventlet
    
    from nova import debugger
    
    if debugger.enabled():
        # turn off thread patching to enable the remote debugger
        eventlet.monkey_patch(os=False, thread=False)
    else:
        eventlet.monkey_patch(os=False, thread=False)

    注:由于上述步骤中,将协程关闭了,所以之后如果涉及到多线程协作流程(例如一次性创建多个虚拟机),将可能出现错误。

  • 相关阅读:
    判断当前时间
    判断页面有没有点击
    js前台与后台数据交互-后台调前台(后台调用、注册客户端脚本)
    js前台与后台数据交互-前台调后台
    关于Cookie
    关于Session
    asp.net中的<%%>的几种形式的用法
    解析客户端脚本、服务器端脚本
    Asp.net--Ajax前后台数据交互
    Asp.Net 前后台交互小结
  • 原文地址:https://www.cnblogs.com/hurongpu/p/8421194.html
Copyright © 2011-2022 走看看