I tried the changes you made; I don't they fix it. You made it iterate inside
__call__, but that is not enough, iteration needs to happen inside
self.profiler.runctx() or the profiler won't capture the execution.
The change I originally suggested seems to work. And it shouldn't break
anything, because PEP 333 guarantees a WSGI application will produce an
iterable, which list() will handle correctly, regardless of whether its a
generator under the covers or not.
Anyhow, paste.debug.profile takes a similar approach to what I'm suggesting. It
creates a nested function that does [].extend(app_iter), and profiles that function.
|