Skip to content

Commit 01cc7ed

Browse files
ericledoakes
authored andcommitted
Fix str of RayTaskError (#5878)
* fix key error * fix
1 parent af7252d commit 01cc7ed

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

python/ray/exceptions.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ def __init__(self,
3232
function_name,
3333
traceback_str,
3434
cause_cls,
35+
proctitle=None,
3536
pid=None,
3637
host=None):
3738
"""Initialize a RayTaskError."""
38-
if setproctitle:
39+
if proctitle:
40+
self.proctitle = proctitle
41+
elif setproctitle:
3942
self.proctitle = setproctitle.getproctitle()
4043
else:
4144
self.proctitle = "ray_worker"
@@ -56,24 +59,22 @@ def as_instanceof_cause(self):
5659
if issubclass(RayTaskError, self.cause_cls):
5760
return self # already satisfied
5861

59-
class cls(self.cause_cls, RayTaskError):
60-
def __init__(self, function_name, traceback_str, cause_cls, pid,
61-
host):
62+
class cls(RayTaskError, self.cause_cls):
63+
def __init__(self, function_name, traceback_str, cause_cls,
64+
proctitle, pid, host):
6265
RayTaskError.__init__(self, function_name, traceback_str,
63-
cause_cls, pid, host)
66+
cause_cls, proctitle, pid, host)
6467

6568
name = "RayTaskError({})".format(self.cause_cls.__name__)
6669
cls.__name__ = name
6770
cls.__qualname__ = name
6871

6972
return cls(self.function_name, self.traceback_str, self.cause_cls,
70-
self.pid, self.host)
71-
cls.original = self
72-
return cls
73+
self.proctitle, self.pid, self.host)
7374

7475
def __str__(self):
7576
"""Format a RayTaskError as a string."""
76-
lines = self.traceback_str.split("\n")
77+
lines = self.traceback_str.strip().split("\n")
7778
out = []
7879
in_worker = False
7980
for line in lines:

0 commit comments

Comments
 (0)