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

__del__ magic method can't access class properties #14285

Open
jvrdnd opened this issue Feb 23, 2021 · 6 comments
Open

__del__ magic method can't access class properties #14285

jvrdnd opened this issue Feb 23, 2021 · 6 comments
Assignees
Labels
bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core P3 Issue moderate in impact or severity
Milestone

Comments

@jvrdnd
Copy link
Contributor

jvrdnd commented Feb 23, 2021

What is the problem?

Class properties cannot be accessed within the __del__ method.

Exception ignored in: <function MyClass.__del__ at 0x7f070cbc5e50>
Traceback (most recent call last):
  File "example.py", line 11, in __del__
AttributeError: 'ActorClass(MyClass)' object has no attribute 'x'

Running Ubuntu 20.04, Python 3.8, Ray 1.1.

Reproduction (REQUIRED)

import ray

ray.init()

@ray.remote
class MyClass(object):
  def __init__(self):
    self.x = 0

  def __del__(self):
    print(self.x)

c = MyClass.remote()
del c

This can be fixed by creating a method within the class e.g. destroy and calling that explicitly before del but this should work within the __del__ method too?

@jvrdnd jvrdnd added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Feb 23, 2021
@stale
Copy link

stale bot commented Jun 23, 2021

Hi, I'm a bot from the Ray team :)

To help human contributors to focus on more relevant issues, I will automatically add the stale label to issues that have had no activity for more than 4 months.

If there is no further activity in the 14 days, the issue will be closed!

  • If you'd like to keep the issue open, just leave any comment, and the stale label will be removed!
  • If you'd like to get more attention to the issue, please tag one of Ray's contributors.

You can always ask for help on our discussion forum or Ray's public slack channel.

@stale stale bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 23, 2021
@rkooo567 rkooo567 added P3 Issue moderate in impact or severity and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Jun 23, 2021
@stale stale bot removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 23, 2021
@Suke0811
Copy link

Hi, any workaround or fix for this? This bug still exists and is a bit of an issue cause I cannot do a close operation. Thanks!

@rkooo567 rkooo567 added triage Needs triage (eg: priority, bug/not-bug, and owning component) and removed P3 Issue moderate in impact or severity labels Jun 2, 2022
@rkooo567 rkooo567 removed their assignment Jun 2, 2022
@rkooo567
Copy link
Contributor

rkooo567 commented Jun 2, 2022

We will triage this again. I think this could be a pretty common usability issue (although there's workaround). Are there other people who also had this issue?

@Suke0811
Copy link

Suke0811 commented Jun 2, 2022

Hi, thanks for that!
I have this issue exists with Ray 1.12.1 on Ubuntu 20.04 and Windows 11.
Currently, as a workaround, I'm catching signals and exceptions to explicitly check if the program is terminated abnormally. However, some situations are cannot be handled well such as process kill in cross-platform environments.
Anyways, it'll be much appreciated if del is functional since it'll only require a single line code as opposed to handling various termination scenarios.

@richardliaw richardliaw added the rllib RLlib related issues label Jun 20, 2022
@ArturNiederfahrenhorst ArturNiederfahrenhorst added core Issues that should be addressed in Ray Core and removed rllib RLlib related issues labels Sep 11, 2022
@zhe-thoughts zhe-thoughts added this to the Core Backlog milestone Oct 25, 2022
@zhe-thoughts zhe-thoughts self-assigned this Oct 25, 2022
@zhe-thoughts zhe-thoughts removed the triage Needs triage (eg: priority, bug/not-bug, and owning component) label Oct 25, 2022
@zhe-thoughts
Copy link
Collaborator

(Context: I'm doing a round of cleanup of waiting-for-triage issues)

@jjyao @rkooo567 Do you think this should be P1 or P2? For now I'm putting on Core Backlog and assigning to myself

@rkooo567
Copy link
Contributor

I think it's P2. But we better fix it someday..

@jjyao jjyao added the P2 Important issue, but not time-critical label Oct 25, 2022
@jjyao jjyao added P3 Issue moderate in impact or severity and removed P2 Important issue, but not time-critical labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core P3 Issue moderate in impact or severity
Projects
None yet
Development

No branches or pull requests

7 participants