Skip to content

Commit

Permalink
Improve logging and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmakait committed Oct 20, 2022
1 parent 7ca7e26 commit b51a096
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions distributed/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,10 +1873,10 @@ def bad_heartbeat_worker(*args, **kwargs):
monkeypatch.setattr(w.scheduler, "heartbeat_worker", bad_heartbeat_worker)

await w.heartbeat()
assert w.status == Status.closed
while s.workers:
await asyncio.sleep(0.01)
assert "Heartbeat to scheduler failed" in logger.getvalue()
assert w.status == Status.running
logs = logger.getvalue()
assert "Failed to communicate with scheduler during heartbeat" in logs
assert "Traceback" in logs


@gen_cluster(nthreads=[("", 1)], worker_kwargs={"heartbeat_interval": "100s"})
Expand Down
5 changes: 2 additions & 3 deletions distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
from distributed.comm.utils import OFFLOAD_THRESHOLD
from distributed.compatibility import randbytes, to_thread
from distributed.core import (
CommClosedError,
ConnectionPool,
Status,
coerce_to_address,
Expand Down Expand Up @@ -1237,8 +1236,8 @@ async def heartbeat(self) -> None:
)
self.bandwidth_workers.clear()
self.bandwidth_types.clear()
except OSError as e:
logger.exception(e)
except OSError:
logger.exception("Failed to communicate with scheduler during heartbeat.")
except Exception as e:
logger.exception("Unexpected exception during heartbeat. Closing worker.")
await self.close()
Expand Down

0 comments on commit b51a096

Please sign in to comment.