Changeset 1580:91f6455e19e4
- Timestamp:
- 10/28/08 12:57:39
(2 months ago)
- Author:
- Dan Blankenberg <dan@bx.psu.edu>
- branch:
- default
- Message:
Use a weakref in metadata to prevent a circular reference possibly interfering with garbage collection: hda/lda (parent) <--> MetadataCollection? (self)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1568 |
r1580 |
|
| 1 | | import sys, logging, copy, shutil |
|---|
| | 1 | import sys, logging, copy, shutil, weakref |
|---|
| 2 | 2 | |
|---|
| 3 | 3 | from galaxy.util import string_as_bool |
|---|
| … | … | |
| 41 | 41 | if self.parent._metadata is None: |
|---|
| 42 | 42 | self.parent._metadata = {} |
|---|
| | 43 | def get_parent( self ): |
|---|
| | 44 | if "_parent" in self.__dict__: |
|---|
| | 45 | return self.__dict__["_parent"]() |
|---|
| | 46 | return None |
|---|
| | 47 | def set_parent( self, parent ): |
|---|
| | 48 | self.__dict__["_parent"] = weakref.ref( parent ) # use weakref to prevent a circular reference interfering with garbage collection: hda/lda (parent) <--> MetadataCollection (self) ; needs to be hashable, so cannot use proxy. |
|---|
| | 49 | parent = property( get_parent, set_parent ) |
|---|
| 43 | 50 | @property |
|---|
| 44 | 51 | def spec( self ): |
|---|
| … | … | |
| 66 | 73 | def __setattr__( self, name, value ): |
|---|
| 67 | 74 | if name == "parent": |
|---|
| 68 | | self.__dict__[name] = value |
|---|
| | 75 | return self.set_parent( value ) |
|---|
| 69 | 76 | else: |
|---|
| 70 | 77 | if name in self.spec: |
|---|