asyncio icon indicating copy to clipboard operation
asyncio copied to clipboard

Add source traceback to transports

Open GoogleCodeExporter opened this issue 10 years ago • 2 comments

Hi,

I created a new "traceback" branch to enhance debug in asyncio. The idea is to 
provide the "head" of an error (traceback where the object was created), not 
only the "tail" (current traceback). I already started this work in tasks, but 
I would like to extend the idea to other objects.

The main change is to add a source traceback to transport classes (socket, 
subprocess, pipe, etc.).

Overall patch:
http://codereview.appspot.com/171720043

I also added a new BaseEventLoop._get_traceback() method which tries uses 
traceback.extract_stack() but also "injects" the source traceback of the 
current task.

This idea may be extended to all logs using exc_info=True: the traceback may be 
retrieved from loop._get_traceback() to get the injected traceback from the 
task.

The new _format_source_traceback() function is used where the logger is called 
with exc_info=True.

Original issue reported on code.google.com by [email protected] on 30 Oct 2014 at 11:55

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter

I'm working on a more generic solution. Instead of adding a source traceback to 
each transport, I added a _current_handle attribute to the event loop. Since 
handles have a source traceback, it becomes possible to retrieve where the 
current handle was scheduled.

Original comment by [email protected] on 13 Nov 2014 at 12:40

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter

Spin-off of this issue:
"asyncio: add BaseEventLoop._current_handle"
http://bugs.python.org/issue23208

Original comment by [email protected] on 9 Jan 2015 at 3:35

GoogleCodeExporter avatar Apr 10 '15 16:04 GoogleCodeExporter