Break reference cycle to fix potential memory leaks for callback handlers.

This commit is contained in:
Lance Stout
2011-10-08 17:31:30 -04:00
parent ccbef6b696
commit 335dc2927b
3 changed files with 10 additions and 4 deletions

View File

@@ -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