[Twisted-Python] RemoteReference decref

Jean-Paul Calderone exarkun at divmod.com
Thu Aug 28 08:51:21 EDT 2008

On Thu, 28 Aug 2008 13:19:50 +0100, A <aldoogy at gmail.com> wrote:
>I'm still working on an Actionscript pb client,
>and have run into a bit of a conundrum with RemoteReference which is using 
>python's built-in __del__  to trigger a decref.
>Actionscript doesn't have destructors so I will need to trigger the decref 
>based on my capture of a clent/server converation I am thinking that the 
>client could do this in proto_answer

This doesn't sound like it makes sense.  You should only decref when the
object is no longer in use.  If you can't do it from a destructor, then
you have to require application code to do it.  The protocol implementation
can't know when the application has finished using the object.

>s -:  ('version', 6)
>r -:  ['version', 6]
>r -:  ['message', 1, 'root', 'login', 1, ['tuple', 'alice'], ['dictionary']]
>s -:  ('answer', 1, ['tuple', 
>'x\x9b\x95\x1c\tJp\xe0\x96]\xf4\xdb\xeb\x13\t9', ('remote', 1)])
>r -:  ['message', 2, 1, 'respond', 1, ['tuple', 
>'\x06\x04\xf1vI\xfeP\xa0\xdfzl(\xd9\x7f!t', ['remote', 1]], ['dictionary']]
>s -:  ('answer', 2, ('remote', 2))
>r -:  ['decref', 1]
>r -:  ['message', 3, 2, 'joinGroup', 1, ['tuple', '#lookingForFourth'], 
>s -:  ('answer', 3, ('remote', 3))
>r -:  ['decref', 2]
>r -:  ['message', 4, 3, 'send', 1, ['tuple', 'You can call me Al.'], 
>s -:  ('message', 1, 1, 'print', 1, ['tuple', '<alice> says: You can call me 
>Al.'], ['dictionary'])
>s -:  ('answer', 4, ['None'])
>r -:  ['decref', 3]

The protocol capture shows decrefs after answers purely by coincidence.  If
the application code being run to generate this kept references to the
objects longer, then you wouldn't see this pattern.


More information about the Twisted-Python mailing list