From d1cc3c99e4e8d1bdb936dbbcc6cb963d6bef2e1e Mon Sep 17 00:00:00 2001 From: homm Date: Sun, 28 Apr 2013 23:25:28 +0400 Subject: [PATCH] Avoid circular references in StackContext and ExceptionStackContext. --- tornado/stack_context.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tornado/stack_context.py b/tornado/stack_context.py index 8804d42d8..ec94a1b8e 100644 --- a/tornado/stack_context.py +++ b/tornado/stack_context.py @@ -151,6 +151,9 @@ class StackContext(object): 'stack_context inconsistency (may be caused by yield ' 'within a "with StackContext" block)') + # Break up a reference to itself to allow for faster GC on CPython. + self.new_contexts = None + class ExceptionStackContext(object): """Specialization of StackContext for exception handling. @@ -190,6 +193,9 @@ class ExceptionStackContext(object): 'stack_context inconsistency (may be caused by yield ' 'within a "with StackContext" block)') + # Break up a reference to itself to allow for faster GC on CPython. + self.new_contexts = None + class NullContext(object): """Resets the `StackContext`. -- 2.47.2