From: Ben Darnell Date: Tue, 5 Jul 2011 01:12:15 +0000 (-0700) Subject: Don't initialize the singleton IOLoop from tearDown X-Git-Tag: v2.1.0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93e22bb7139cc6784793a429271449ae3bfd3fc7;p=thirdparty%2Ftornado.git Don't initialize the singleton IOLoop from tearDown --- 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):