From 93e22bb7139cc6784793a429271449ae3bfd3fc7 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 4 Jul 2011 18:12:15 -0700 Subject: [PATCH] Don't initialize the singleton IOLoop from tearDown --- tornado/testing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tornado/testing.py b/tornado/testing.py index c2156173b..78cc5234d 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -29,9 +29,10 @@ import logging import os import sys import time -import tornado.ioloop import unittest +from tornado.ioloop import IOLoop + _next_port = 10000 def get_unused_port(): """Returns a (hopefully) unused port number.""" @@ -96,7 +97,8 @@ class AsyncTestCase(unittest.TestCase): self.io_loop = self.get_new_ioloop() def tearDown(self): - if self.io_loop is not tornado.ioloop.IOLoop.instance(): + if (not IOLoop.initialized() or + self.io_loop is not IOLoop.instance()): # Try to clean up any file descriptors left open in the ioloop. # This avoids leaks, especially when tests are run repeatedly # in the same process with autoreload (because curl does not @@ -109,7 +111,7 @@ class AsyncTestCase(unittest.TestCase): subclasses for tests that require a specific IOLoop (usually the singleton). ''' - return tornado.ioloop.IOLoop() + return IOLoop() @contextlib.contextmanager def _stack_context(self): -- 2.47.3