Skip to content

Commit

Permalink
Handle stream is None case in TCP comm finalizer (#4631)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau authored Mar 25, 2021
1 parent 3b8b97e commit 43859e2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions distributed/comm/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ def _read_extra(self):

def _get_finalizer(self):
def finalize(stream=self.stream, r=repr(self)):
if not stream.closed():
logger.warning("Closing dangling stream in %s" % (r,))
# stream is None if a StreamClosedError is raised during interpreter shutdown
if stream is not None and not stream.closed():
logger.warning(f"Closing dangling stream in {r}")
stream.close()

return finalize
Expand Down

0 comments on commit 43859e2

Please sign in to comment.