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)

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

  • 相关阅读:
    广告效果滚动
    判断背景图片是否加载成功
    css3创建多边形clip属性,可用来绘制不规则图形了
    不允许用户选中文本的两种方法
    栈类模板设计及应用
    HDOJ 题目类型
    极大团数量模板
    HDU 1522 Marriage is Stable 稳定婚姻匹配
    字符串类设计与应用
    正向与反向拓扑排序的区别(hdu 1285 确定比赛名次和hdu 4857 逃生)
  • 原文地址:https://www.cnblogs.com/hurongpu/p/8421194.html
Copyright © 2011-2022 走看看