]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Cleanup Subprocess when tearing down AsyncTestCase 1246/head
authorHeewa Barfchin <heewa.b@gmail.com>
Sat, 8 Nov 2014 19:40:51 +0000 (14:40 -0500)
committerHeewa Barfchin <heewa.b@gmail.com>
Sat, 8 Nov 2014 19:43:49 +0000 (14:43 -0500)
Since an ioloop is created and destroyed between a test's `setUp` and
`tearDown`, and Subprocess holds on to an ioloop until `uninitialize`,
this allows the next test case to use Subprocess correctly.

tornado/testing.py

index 4d85abe997372611e1bc2d1a23287329f967aafd..4511863b7f90d7be7386fdd43340480f0d3c3754 100644 (file)
@@ -19,6 +19,7 @@ try:
     from tornado.simple_httpclient import SimpleAsyncHTTPClient
     from tornado.ioloop import IOLoop, TimeoutError
     from tornado import netutil
+    from tornado.process import Subprocess
 except ImportError:
     # These modules are not importable on app engine.  Parts of this module
     # won't work, but e.g. LogTrapTestCase and main() will.
@@ -28,6 +29,7 @@ except ImportError:
     IOLoop = None
     netutil = None
     SimpleAsyncHTTPClient = None
+    Subprocess = None
 from tornado.log import gen_log, app_log
 from tornado.stack_context import ExceptionStackContext
 from tornado.util import raise_exc_info, basestring_type
@@ -214,6 +216,8 @@ class AsyncTestCase(unittest.TestCase):
         self.io_loop.make_current()
 
     def tearDown(self):
+        # Clean up Subprocess, so it can be used again with a new ioloop.
+        Subprocess.uninitialize()
         self.io_loop.clear_current()
         if (not IOLoop.initialized() or
                 self.io_loop is not IOLoop.instance()):