From 70af52d74c3f4253791120be4016f108aa966b4d Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sun, 13 Feb 2011 16:28:06 -0500 Subject: Make one-off Callbacks ready for deletion after the prerun step. Waiting until the actual run step means that the handler is not marked for deletion when checked in the __spawn_event() thread, causing the callback to stay in the handler list. --- sleekxmpp/xmlstream/handler/callback.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sleekxmpp/xmlstream/handler') diff --git a/sleekxmpp/xmlstream/handler/callback.py b/sleekxmpp/xmlstream/handler/callback.py index f0a72853..cfd3c43c 100644 --- a/sleekxmpp/xmlstream/handler/callback.py +++ b/sleekxmpp/xmlstream/handler/callback.py @@ -62,6 +62,8 @@ class Callback(BaseHandler): payload -- The matched stanza object. """ BaseHandler.prerun(self, payload) + if self._once: + self._destroy = True if self._instream: self.run(payload, True) -- cgit v1.2.3 From 9004e8bbf2c29d23fad20467791d9a8224d4bdb3 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 14 Feb 2011 11:13:41 -0500 Subject: Break references that can prevent garbage collection. --- sleekxmpp/xmlstream/handler/callback.py | 1 + 1 file changed, 1 insertion(+) (limited to 'sleekxmpp/xmlstream/handler') diff --git a/sleekxmpp/xmlstream/handler/callback.py b/sleekxmpp/xmlstream/handler/callback.py index cfd3c43c..f1fda805 100644 --- a/sleekxmpp/xmlstream/handler/callback.py +++ b/sleekxmpp/xmlstream/handler/callback.py @@ -84,3 +84,4 @@ class Callback(BaseHandler): self._pointer(payload) if self._once: self._destroy = True + del self._pointer -- cgit v1.2.3 From e0f9025e7c6fe51243222aeb684b94eda1a2be5f Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 14 Feb 2011 11:30:04 -0500 Subject: More attempts at fixing garbage collection. Don't keep a reference to stanzas in Callback objects. --- sleekxmpp/xmlstream/handler/callback.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'sleekxmpp/xmlstream/handler') diff --git a/sleekxmpp/xmlstream/handler/callback.py b/sleekxmpp/xmlstream/handler/callback.py index f1fda805..7fadab43 100644 --- a/sleekxmpp/xmlstream/handler/callback.py +++ b/sleekxmpp/xmlstream/handler/callback.py @@ -61,7 +61,6 @@ class Callback(BaseHandler): Arguments: payload -- The matched stanza object. """ - BaseHandler.prerun(self, payload) if self._once: self._destroy = True if self._instream: @@ -80,7 +79,6 @@ class Callback(BaseHandler): Defaults to False. """ if not self._instream or instream: - BaseHandler.run(self, payload) self._pointer(payload) if self._once: self._destroy = True -- cgit v1.2.3 From 75584d7ad74b284d30164cde0b5efec2c845d207 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 14 Feb 2011 13:49:43 -0500 Subject: Remap old method names in a better way. This should prevent some reference cycles that will cause garbage collection issues. --- sleekxmpp/xmlstream/handler/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/xmlstream/handler') diff --git a/sleekxmpp/xmlstream/handler/base.py b/sleekxmpp/xmlstream/handler/base.py index 9c704ec6..6ec9b6a3 100644 --- a/sleekxmpp/xmlstream/handler/base.py +++ b/sleekxmpp/xmlstream/handler/base.py @@ -42,8 +42,6 @@ class BaseHandler(object): this handler. stream -- The XMLStream instance the handler should monitor. """ - self.checkDelete = self.check_delete - self.name = name self.stream = stream self._destroy = False @@ -87,3 +85,8 @@ class BaseHandler(object): handlers. """ return self._destroy + + +# To comply with PEP8, method names now use underscores. +# Deprecated method names are re-mapped for backwards compatibility. +BaseHandler.checkDelete = BaseHandler.check_delete -- cgit v1.2.3