Skip to content

Commit

Permalink
Clean up some uncollectable garbage in the test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Nov 6, 2013
1 parent 6f56d1a commit 372ebb5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tornado/test/stack_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@ def test_yield_in_with(self):
@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.
Expand All @@ -238,6 +239,11 @@ def f():
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):
Expand Down

0 comments on commit 372ebb5

Please sign in to comment.