Skip to content

Commit

Permalink
Log original exception upon compute failure (#5387)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter authored Oct 4, 2021
1 parent cf018a1 commit 92d830f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
25 changes: 7 additions & 18 deletions distributed/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,28 +739,17 @@ async def test_dont_overlap_communications_to_same_worker(c, s, a, b):
assert l1["stop"] < l2["start"]


@pytest.mark.avoid_ci
@gen_cluster(client=True)
async def test_log_exception_on_failed_task(c, s, a, b):
with tmpfile() as fn:
fh = logging.FileHandler(fn)
try:
from distributed.worker import logger

logger.addHandler(fh)
with captured_logger("distributed.worker") as logger:
future = c.submit(div, 1, 0)
await wait(future)

future = c.submit(div, 1, 0)
await wait(future)

await asyncio.sleep(0.1)
fh.flush()
with open(fn) as f:
text = f.read()
await asyncio.sleep(0.1)

assert "ZeroDivisionError" in text
assert "Exception" in text
finally:
logger.removeHandler(fh)
text = logger.getvalue()
assert "ZeroDivisionError" in text
assert "Exception" in text


@gen_cluster(client=True)
Expand Down
2 changes: 1 addition & 1 deletion distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3088,7 +3088,7 @@ async def execute(self, key, *, stimulus_id):
str(funcname(function))[:1000],
convert_args_to_str(args2, max_len=1000),
convert_kwargs_to_str(kwargs2, max_len=1000),
ts.exception_text,
result["exception_text"],
)
recommendations[ts] = (
"error",
Expand Down

0 comments on commit 92d830f

Please sign in to comment.