bad Python code exists in practice, that there are frameworks in the Python community that advocate for sloppy code, that there are widely used modules with security problems or bad general design, that there are indeed Wifi hotspot login pages that are horrible and indeed written in Python, that there are well written Wifi login pages in PHP (I don't actually believe that), that I am hugely biased and that my sample size is waaaaaaaaaaaaaaaaay too small.
self.func = func self.__name__ = func.__name__ self.__doc__ = func.__doc__ self.__module__ = func.__module__ def __get__(self, obj, type=None): if obj is None: return self value = obj.__dict__.get(self.__name__, missing) if value is missing: value = self.func(obj) obj.__dict__[self.__name__] = value return value
'filename: %s' % frame.f_code.co_filename print 'current line: %d' % frame.f_lineno loc = dict((k, v) for k, v in frame.f_locals.iteritems() if not k.startswith('__')) print 'local variables: %s' % loc
... for x in xrange(10): ... time.sleep(1) ... >>> threading.Thread(target=foo).start() >>> dump_threads() Thread #4302381056 File "lib/python2.7/threading.py", line 483, in run self.__target(*self.__args, **self.__kwargs) File "<stdin>", line 3, in foo time.sleep(1) Thread #140735295412576 File "<stdin>", line 1, in <module> dump_threads() File "<stdin>", line 4, in dump_threads print ''.join(traceback.format_stack(frame)).rstrip()
runs longer than N seconds • Permanent background thread • Request start -> set marker • Request end -> remove marker • If marker active for more than N seconds -> log stacktrace