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

[Bug] isinstance(self, Client) will never be True #45

Closed
eddiebergman opened this issue Jul 21, 2023 · 6 comments · Fixed by #48 or #50
Closed

[Bug] isinstance(self, Client) will never be True #45

eddiebergman opened this issue Jul 21, 2023 · 6 comments · Fixed by #48 or #50
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@eddiebergman
Copy link
Contributor

Found this while looking for where the Client is located.

if hasattr(self, "client") and isinstance(self, Client):

@Neeratyoy
Copy link
Collaborator

Does it mean that the client is never destructed in this code base or could be a Dask version-related thing?

@eddiebergman
Copy link
Contributor Author

Not a dask version related thing, it's basically doing:

class A:

    def __del__(self):
        if isisntance(self, Client):
            ...

Also relying on __del__ for for cleanup is usually a bad practice and can lead to problems if DEHB would be the last thing to be cleaned up.

The correct way, is that Dask Clients can be used as context managers and is likely what you want to have around your hot loop. In the case of a user supplied dask, not sure what you want, might be bad form to automatically shut down their client unless they've specified it somehow.

@Bronzila Bronzila added the bug Something isn't working label Jul 22, 2023
@Neeratyoy
Copy link
Collaborator

Okay thanks, so 2 aspects here as I see:

  • There is a bug here and the check should be isinstance(self, self.client):
  • Whether we should use __del__ or not

@Neeratyoy Neeratyoy added the good first issue Good for newcomers label Jul 27, 2023
Bronzila added a commit that referenced this issue Jul 30, 2023
@Bronzila
Copy link
Collaborator

Bronzila commented Aug 1, 2023

I think using the Dask Client as a context manager would definetly be an improvement. However this would involve quite some refactoring and since we are planing to release on Thursday, I would propose to simply fix the bug for now and create a new issue regarding using Dask Clients as context managers. What do you think? @eddiebergman @Neeratyoy

@eddiebergman
Copy link
Contributor Author

Sounds fine to me, as long as it works generally at the moment, then fire away.

@Neeratyoy
Copy link
Collaborator

I second @eddiebergman!
Just keep an issue alive to remind us :)

@Bronzila Bronzila linked a pull request Aug 2, 2023 that will close this issue
Bronzila added a commit that referenced this issue Aug 2, 2023
@Bronzila Bronzila closed this as completed Aug 2, 2023
@Bronzila Bronzila mentioned this issue Aug 2, 2023
@Bronzila Bronzila linked a pull request Aug 2, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants