gh-125434: Display thread name in faulthandler#132016
Conversation
|
Example: import faulthandler
import time
import threading
threading.current_thread().name = "main_thread"
thr = threading.Thread(target=time.sleep, args=(2,), name="sleeper")
thr.start()
faulthandler.dump_traceback()
thr.join()Output: |
|
What about windows version? When I looked into it, I stopped on needing to move initialization from Modules/_threadmodule.c to Python/* and wasn't confident is it worth or no. |
I prefer to start only with Unix/BSD since the implementation is simpler. The Windows implementation can be added later. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
_PYTHREAD_NAME_MAXLEN may be undefined.
Oh right, I modified the code to require the macro in two code paths using it. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
This would be a nice enhancement, but I think that it is better to use a buffer of size 100 than _PYTHREAD_NAME_MAXLEN.
- It will work if
_PYTHREAD_NAME_MAXLENis not defined. In most cases the name is shorter than 100 bytes. - Even if
_PYTHREAD_NAME_MAXLENis defined, it is only our estimation. The real limit may be larger in new versions of the OS.
Oh ok. I changed the buffer size to 100 bytes. |
|
Merged, thanks for reviews. |
Uh oh!
There was an error while loading. Please reload this page.