2016-07-19 11 views
0

Jedes Mal, wenn ich einen Debug-Prozess für Python-Code in Visual Studio 2015 starte, muss ich viele Zeilen in der Python-Bibliothek durchlaufen, die ausgeführt werden, bevor mein Code geladen wird. Zum Beispiel gibt es unbeaufsichtigt Haltepunkte (die in der Schnittstelle nicht dargestellt sind) an der Linie 143, 147 und 184 von site.pyWie werden unbeaufsichtigte Breakpoints im Python-Bibliothekscode beseitigt?

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 

< ... übersprungenen ...>

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 

auch die gleiche mit Linie 18 von genericpath.py:

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 

All macht dies jede Debug-Sitzung sehr sloooow. Wie kann ich diese Orte ausblenden, damit sie die Ausführung nicht mehr stoppen? Ich benutze Python 2.7.10 und Visual Studio 2015 unter Windows 7 x64.

+0

Das klingt, als ob Sie eine Einstellung haben, die bei Datei-I/O bricht. – user2357112

+0

Vielleicht, aber ich habe sie nicht gesetzt. Es ist etwas von den Standardeinstellungen. Löschen aller Haltepunkte hilft, das Problem zu lösen. – Dingo

Antwort

1

Wählen Sie das Debug Eintrag im Menü, und wählen Sie dann die alle Haltepunkte Option Löschen. Die Tastenkombination Strg + Shift + F9 wird das gleiche erreichen.

+0

Vielen Dank! Das hilft :) – Dingo