summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/handler/base.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-10-08 17:31:30 -0400
committerLance Stout <lancestout@gmail.com>2011-10-08 17:31:30 -0400
commit335dc2927bf874aa3ee3d4154257040b3b59db1a (patch)
tree067c15ac5713fed951dd0d9d09db79fa8f7a6327 /sleekxmpp/xmlstream/handler/base.py
parentccbef6b6968b4d50192b290404869e18d33c8414 (diff)
downloadslixmpp-335dc2927bf874aa3ee3d4154257040b3b59db1a.tar.gz
slixmpp-335dc2927bf874aa3ee3d4154257040b3b59db1a.tar.bz2
slixmpp-335dc2927bf874aa3ee3d4154257040b3b59db1a.tar.xz
slixmpp-335dc2927bf874aa3ee3d4154257040b3b59db1a.zip
Break reference cycle to fix potential memory leaks for callback handlers.
Diffstat (limited to 'sleekxmpp/xmlstream/handler/base.py')
-rw-r--r--sleekxmpp/xmlstream/handler/base.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/handler/base.py b/sleekxmpp/xmlstream/handler/base.py
index 6ec9b6a3..7f05c757 100644
--- a/sleekxmpp/xmlstream/handler/base.py
+++ b/sleekxmpp/xmlstream/handler/base.py
@@ -6,6 +6,8 @@
See the file LICENSE for copying permission.
"""
+import weakref
+
class BaseHandler(object):
@@ -43,7 +45,10 @@ class BaseHandler(object):
stream -- The XMLStream instance the handler should monitor.
"""
self.name = name
- self.stream = stream
+ if stream is not None:
+ self.stream = weakref.ref(stream)
+ else:
+ self.stream = None
self._destroy = False
self._payload = None
self._matcher = matcher