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

DM-31507 Modify data-structures to aid ref counting #199

Merged
merged 1 commit into from Aug 26, 2021

Conversation

natelust
Copy link
Contributor

It is desirable that variables get cleaned up when they go out of
scope, meaning that their ref count must go to zero. Some objects
kept closures or circular references which means they must be
cleaned by the garbage collector which can happen at unpredictable
times. Make these objects able to be dropped with reference counting.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

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

Looks good.

@@ -79,30 +77,32 @@ def __init__(self, butler: Butler, quantum: Quantum):
for refs in quantum.outputs.values():
for ref in refs:
self.allOutputs.add((ref.datasetType, ref.dataId))
self._butler_ = butler
Copy link
Contributor

Choose a reason for hiding this comment

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

Cannot you do self.__butler instead and avoid __getattribute__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really was trying to be difficult, but really this is pragmatic enough I suppose.

@@ -170,13 +174,17 @@ def __init__(self, config=None, name=None, parentTask=None, log=None):
self._display = lsstDebug.Info(self.__module__).display
else:
self._display = None
self._taskDict[self._fullName] = self
self._taskDict[self._fullName] = weakref.ref(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to use WeakValueDictionary for self._taskDict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont know, I thought about that too, but then thought there might be some value to being able to see what keys were there at some point even if the reference was gone. Though this would probably only happen in the most obscure of debug cases, I was ready to punt thinking about it further to get the ticket in.

It is desirable that variables get cleaned up when they go out of
scope, meaning that their ref count must go to zero. Some objects
kept closures or circular references which means they must be
cleaned by the garbage collector which can happen at unpredictable
times. Make these objects able to be dropped with reference counting.
@natelust natelust merged commit 8a29dd8 into master Aug 26, 2021
@natelust natelust deleted the tickets/DM-31507 branch August 26, 2021 18:24
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.

None yet

2 participants