如何摆脱 Python 库代码中的无人值守断点?

How to get rid of unattended breakpoints in Python library code?

每次在Visual Studio 2015开始调试Python代码的时候,都需要在Python库的几行执行很多停顿在加载我的代码之前。比如site.py

的143、147、184行有无人值守的断点(界面上没有显示)
def addpackage(sitedir, name, known_paths):
"""Process a .pth file within the site-packages directory:
   For each line in the file, either combine it with sitedir to a path
   and add that to known_paths, or execute it if it starts with 'import '.
"""
if known_paths is None:
    _init_pathinfo()
    reset = 1
else:
    reset = 0
fullname = os.path.join(sitedir, name)
try:
    f = open(fullname, "rU")  # <-- Line 143
except IOError:
    return
with f:
    for n, line in enumerate(f):  #  <-- Line 147
        if line.startswith("#"):
            continue
        try:
            if line.startswith(("import ", "import\t")):
                exec line
                continue
            line = line.rstrip()
            dir, dircase = makepath(sitedir, line)
            if not dircase in known_paths and os.path.exists(dir):
                sys.path.append(dir)
                known_paths.add(dircase)
        except Exception as err:
            print >>sys.stderr, "Error processing line {:d} of {}:\n".format(
                n+1, fullname)
            for record in traceback.format_exception(*sys.exc_info()):
                for line in record.splitlines():
                    print >>sys.stderr, '  '+line
            print >>sys.stderr, "\nRemainder of file ignored"
            break
if reset:
    known_paths = None
return known_paths

<...跳过...>

def addsitedir(sitedir, known_paths=None):
        """Add 'sitedir' argument to sys.path if missing and handle .pth files in
        'sitedir'"""
        if known_paths is None:
            known_paths = _init_pathinfo()
            reset = 1
        else:
            reset = 0
        sitedir, sitedircase = makepath(sitedir)
        if not sitedircase in known_paths:
            sys.path.append(sitedir)        # Add path component
        try:
            names = os.listdir(sitedir)  # <-- Line 184, here it stops for a lot of times
        except os.error:
            return
        dotpth = os.extsep + "pth"
        names = [name for name in names if name.endswith(dotpth)]
        for name in sorted(names):
            addpackage(sitedir, name, known_paths)
        if reset:
            known_paths = None
        return known_paths

此外,与genericpath.py的第18行相同:

def exists(path):
    """Test whether a path exists.  Returns False for broken symbolic links"""
    try:
        os.stat(path)  #  <-- Line 18, breaks here very many times
    except os.error:
        return False
    return True

所有这些使得每个调试会话都非常缓慢。我怎样才能掩盖这些地方,使他们不再停止执行? 我在 Windows 7 x64.

下使用 Python 2.7.10 和 Visual Studio 2015

Select 菜单中的 Debug 项,然后 select Delete All Breakpoints 选项。键盘快捷键 Ctrl+Shift+F9 将完成相同的操作。