python / asyncio

asyncio historical repository
https://docs.python.org/3/library/asyncio.html
1.04k stars 177 forks source link

Add source traceback to transports #212

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 victor.s...@gmail.com on 30 Oct 2014 at 11:55

GoogleCodeExporter commented 9 years ago
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 victor.s...@gmail.com on 13 Nov 2014 at 12:40

GoogleCodeExporter commented 9 years ago
Spin-off of this issue:
"asyncio: add BaseEventLoop._current_handle"
http://bugs.python.org/issue23208

Original comment by victor.s...@gmail.com on 9 Jan 2015 at 3:35