OK, I totally didn't understand what tracemalloc is, and I still don't,
except I now know it's a new low-level debugging module that you added.

I think there should be no references to tracemalloc in the asyncio
package; instead, there should be a hook (maybe the error handler that Yuri
is adding???) so tracemalloc fans can help themselves.

Having a new debug flag on the event loop that defaults to False sounds
like a fine solution (I don't like the existing _DEBUG thing much anyway).
Please make getting and setting it methods (every event loop API is a
method). Perhaps it ought to be an integer level instead of a bool?



On Thu, Feb 13, 2014 at 3:46 AM, Victor Stinner <[email protected]>wrote:

> 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
>



-- 
--Guido van Rossum (python.org/~guido)

Reply via email to