Skip to content

Commit

Permalink
Cleanup Subprocess when tearing down AsyncTestCase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
heewa committed Nov 8, 2014
1 parent 1502895 commit 21227ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tornado/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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.
Expand All @@ -28,6 +29,7 @@
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
Expand Down Expand Up @@ -214,6 +216,8 @@ def setUp(self):
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()):
Expand Down

0 comments on commit 21227ff

Please sign in to comment.