Add thread details to the exception (#5360)

* thread details

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andy Kipp 2024-04-24 11:15:40 +02:00 committed by GitHub
parent af9c3afa23
commit 273f12d329
Failed to generate hash of commit
3 changed files with 13 additions and 3 deletions

View file

@ -1,6 +1,6 @@
**Added:**
* Added detailed thread name to thread exceptions.
* Added thread class, name, func and alias names to thread exception for easy understanding the source of issue.
**Changed:**

View file

@ -103,7 +103,14 @@ class PopenThread(threading.Thread):
raise
self.pid = proc.pid
self.name = repr({"name": self.name, "cmd": args, "pid": self.pid})
self.name = repr(
{
"cls": self.__class__.__name__,
"name": self.name,
"cmd": args,
"pid": self.pid,
}
)
self.universal_newlines = uninew = proc.universal_newlines
if uninew:
self.encoding = enc = env.get("XONSH_ENCODING")

View file

@ -351,9 +351,12 @@ def partial_proxy(f):
def get_proc_proxy_name(cls):
func_name = cls.f
if type(cls.f) is functools.partial:
func_name = getattr(cls.f.args[0], "__name__", cls.f)
func_name = getattr(
cls.f.args[0], "__name__", getattr(cls.f, "__name__", cls.f)
)
return repr(
{
"cls": cls.__class__.__name__,
"name": getattr(cls, "name", None),
"func": func_name,
"alias": cls.env.get("__ALIAS_NAME", None),