Skip to content

Commit

Permalink
Include addresses in closed comm repr (#5203)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau committed Aug 13, 2021
1 parent 2298861 commit 17cd4db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 7 additions & 10 deletions distributed/comm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,13 @@ def handshake_configuration(local, remote):
return out

def __repr__(self):
clsname = self.__class__.__name__
if self.closed():
return f"<closed {clsname}>"
else:
return "<{} {} local={} remote={}>".format(
clsname,
self.name or "",
self.local_address,
self.peer_address,
)
return "<{}{} {} local={} remote={}>".format(
self.__class__.__name__,
" (closed)" if self.closed() else "",
self.name or "",
self.local_address,
self.peer_address,
)


class Listener(ABC):
Expand Down
4 changes: 4 additions & 0 deletions distributed/comm/tests/test_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,8 +1199,12 @@ async def check_repr(a, b):
assert "closed" not in repr(b)
await a.close()
assert "closed" in repr(a)
assert a.local_address in repr(a)
assert b.peer_address in repr(a)
await b.close()
assert "closed" in repr(b)
assert a.local_address in repr(b)
assert b.peer_address in repr(b)


@pytest.mark.asyncio
Expand Down

0 comments on commit 17cd4db

Please sign in to comment.