From: Carlos P. <cpa...@ce...> - 2016-01-27 17:29:53
|
Forget this patch. If this approach is to be followed, some more things need to be done: -clean the _parentObj ref in TaurusModel.cleanUp -remove the TaurusAttribute.__parentDevice member (created in constructor) since it is unneeded (also, see discussion in https://sf.net/p/tauruslib/tickets/256/#02a4 ) On Wed 27 January 2016 16:36:30 cpa...@ce... wrote: > From: cpascual <cpa...@ce...> > > TaurusModel stores a weak ref to its parent. If the parent is not > referenced elsewhere, the getParentObj API does not work as expected. > Fix by making TaurusModel store a strong ref to parent instead of a > weak one. > --- > lib/taurus/core/taurusmodel.py | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/lib/taurus/core/taurusmodel.py > b/lib/taurus/core/taurusmodel.py index 4f11b9d..e5cbc4f 100644 > --- a/lib/taurus/core/taurusmodel.py > +++ b/lib/taurus/core/taurusmodel.py > @@ -58,10 +58,7 @@ class TaurusModel(Logger): > serializationMode = s_obj.getSerializationMode() > self._serialization_mode = serializationMode > > - try: > - self._parentObj = weakref.ref(parent) > - except Exception: > - self._parentObj = None > + self._parentObj = parent > self._listeners = [] > > def __str__name__(self, name): > @@ -121,8 +118,7 @@ class TaurusModel(Logger): > > #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ > -~-~-~- > > def getParentObj(self): > - if self._parentObj is None: return None > - return self._parentObj() > + return self._parentObj > > def getChildObj(self,child_name): > return None -- +----------------------------------------------------+ Carlos Pascual Izarra Scientific Software Coordinator Computing Division ALBA Synchrotron [http://www.albasynchrotron.es] Carrer de la Llum 2-26 E-08290 Cerdanyola del Valles (Barcelona), Spain E-mail: cpa...@ce... Phone: +34 93 592 4428 +----------------------------------------------------+ |