2014-02-10 0:30 GMT+01:00 Guido van Rossum <[email protected]>: > For this particular patch I don't see why this couldn't always be on -- it > seems to only do extra work when logging this particular error condition, > which shouldn't happen at all.
I don't want to advice people to enable tracemalloc by default "just" to get the traceback where asyncio objects were created, because tracemalloc makes your program 2x slower and uses 2x more memory. I would prefer to more lightway solution built in asyncio: store the traceback where Handle and Future were created in these objects. But it requires to add a DEBUG flag somewhere. I proposed asyncio.DEBUG once, but Guido wrote that he doesn't like such global flag. We may pass the loop instance almost everywhere (at least to Handle and Future constructors) for the new exception handler API, so the can be maybe be added to BaseEventLoop: a new debug attribute, False by default? But we already have asyncio.tasks._DEBUG which must be global :-/ (it doesn't have access to the loop) Maybe you're fine with two flags? One global (tasks._DEBUG), one per event loop. > However I do think the entire second > traceback should be logged in a single logger.error() call, rather than two > calls per frame. Ah yes. I wrote this patch quickly to show you the output that I'm expecting. I wrote the patch quickly. > And isn't there a helper function in traceback.py that can > do the formatting for you? Tracemalloc has its own traceback objects which are wrappers to raw tuples built in the C tracemalloc module (_tracemalloc). It's unrelated to the traceback module. A new formatting method can maybe be added to the tracemalloc.Traceback object. Oh you know what? I just wrote a patch to add it :-) http://bugs.python.org/issue20616 Victor
