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

[Serve] gate __del__ call behind hasattr check #18773

Merged

Conversation

architkulkarni
Copy link
Contributor

Why are these changes needed?

Related issue number

Closes #18772

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@@ -355,7 +355,8 @@ async def prepare_for_shutdown(self):
# We set the del method to noop after succssifully calling it so the
# destructor is called only once.
try:
self.callable.__del__()
if hasattr(self.callable, "__del__"):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's better to put this outside the whole try-except block, but it's probably not very consequential

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be totally fine!

@@ -355,7 +355,8 @@ async def prepare_for_shutdown(self):
# We set the del method to noop after succssifully calling it so the
# destructor is called only once.
try:
self.callable.__del__()
if hasattr(self.callable, "__del__"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be totally fine!

@simon-mo
Copy link
Contributor

note to self: this wasn't caught during that commit because the errors are silently logged but not thrown. In the future, we can add logging output test to capture any unexpected output.

@simon-mo simon-mo merged commit aa6625e into ray-project:master Sep 21, 2021
@davidberenstein1957
Copy link

I was having the same issue. @simon-mo why isn't this set to del self.callable?

@simon-mo
Copy link
Contributor

del self.callable doesn't trigger the gc and is the del function is not guarantee to run immediately.

@davidberenstein1957 are you still seeing this issue in ray nightly? https://docs.ray.io/en/master/installation.html#daily-releases-nightlies

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.

[Serve] [Bug] Redeploying function causes "AttributeError: 'function' object has no attribute '__del__'"
3 participants