From 372ebb561eb4f0b411554457e0bdd5ada643ca74 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Wed, 6 Nov 2013 16:44:15 -0500 Subject: [PATCH] Clean up some uncollectable garbage in the test suite. --- tornado/test/stack_context_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tornado/test/stack_context_test.py b/tornado/test/stack_context_test.py index 5f62852f..29193305 100644 --- a/tornado/test/stack_context_test.py +++ b/tornado/test/stack_context_test.py @@ -220,12 +220,13 @@ class StackContextTest(AsyncTestCase): @gen.engine def f(): try: + self.callback = yield gen.Callback('a') with StackContext(functools.partial(self.context, 'c1')): # This yield is a problem: the generator will be suspended # and the StackContext's __exit__ is not called yet, so # the context will be left on _state.contexts for anything # that runs before the yield resolves. - yield gen.Task(self.io_loop.add_callback) + yield gen.Wait('a') except StackContextInconsistentError: # In python <= 3.3, this suspended generator is never garbage # collected, so it remains suspended in the 'yield' forever. @@ -238,6 +239,11 @@ class StackContextTest(AsyncTestCase): with self.assertRaises(StackContextInconsistentError): f() self.wait() + # Cleanup: to avoid GC warnings (which for some reason only seem + # to show up on py33-asyncio), invoke the callback (which will do + # nothing since the gen.Runner is already finished) and delete it. + self.callback() + del self.callback @gen_test def test_yield_outside_with(self):