Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle stream is None case in TCP comm finalizer #4631

Merged
merged 1 commit into from
Mar 25, 2021

Conversation

jrbourbeau
Copy link
Member

Some Dask users reported running into the following error coming from the TCP comm finalizer method

Exception ignored in: <finalize object at 0x7fc093a9f1a0; dead>
Traceback (most recent call last):

  File "distributed/comm/tcp.py", line 172, in finalize
    if not stream.closed():
AttributeError: 'NoneType' object has no attribute 'closed'

Looking at the TCP comm, there are some code paths where we will set the stream to None:

except StreamClosedError as e:
self.stream = None
self._closed = True
if not sys.is_finalizing():
convert_stream_closed_error(self, e)

In particular, when sys.is_finalizing() is True we don't raise an error and could end up with

AttributeError: 'NoneType' object has no attribute 'closed'

when the finalizer for the comm is run during interpreter shutdown.

This PR adds a check to the corresponding finalize function to make sure stream is not None before attempting to call stream.close()

@mrocklin mrocklin merged commit 43859e2 into dask:main Mar 25, 2021
@jrbourbeau jrbourbeau deleted the tcp-finalizer-fixup branch March 25, 2021 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants