Getting Bad file descriptor when running Tornado AsyncHTTPTestCase
- by Will
When running a test using the Tornado AsyncHTTPTestCase I'm getting a stack trace that isn't related to the test. The test is passing so this is probably happening on the test clean up?
I'm using Python 2.7.2, Tornado 2.2.
The test code is:
class AllServersHandlerTest(AsyncHTTPTestCase):
endpoint = AllServersHandler.endpoint # '/rest/test/'
def test_server_status_with_advertiser(self):
on_new_host(None, '127.0.0.1')
response = self.fetch(self.endpoint, method='GET')
result = json.loads(response.body, 'utf8').get('data')
self.assertEquals(['127.0.0.1'], result)
The test passes ok, but I get the following stack trace from the Tornado server.
OSError: [Errno 9] Bad file descriptor
INFO:root:200 POST /rest/serverStatuses (127.0.0.1) 0.00ms
DEBUG:root:error closing fd 688
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\tornado-2.2-py2.7.egg\tornado\ioloop.py", line 173, in close
os.close(fd)
OSError: [Errno 9] Bad file descriptor
Any ideas how to cleanly shutdown the test case?