import threading def func(frame, event, arg): try: threading.currentThread() except: print 'Ok, I have no clues why there could be an error here...' return func import sys sys.settrace(func) import tokenize def next(token, string, start, end, line): raise tokenize.StopTokenizing() def getEmptyString(): return '' tokenize.tokenize(getEmptyString, next)