Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:33:22+00:00 2026-06-01T10:33:22+00:00

When running a test using the Tornado AsyncHTTPTestCase I’m getting a stack trace that

  • 0

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):

    def get_app(self):
        return Application([('/rest/test/', AllServersHandler)])

    def test_server_status_with_advertiser(self):
        on_new_host(None, '127.0.0.1')
        response = self.fetch('/rest/test/', 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:33:24+00:00Added an answer on June 1, 2026 at 10:33 am

    I dug around in the tornado code and found that this code is setting the all_fds to True which then causes the stack trace in io_loop.close():

    def tearDown(self):
        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
            # set FD_CLOEXEC on its file descriptors)
            self.io_loop.close(all_fds=True)
        super(AsyncTestCase, self).tearDown()
    

    So, overriding the tearDown() in the test class stops the stack trace.

    class AllServersHandlerTest(AsyncHTTPTestCase):
    
        def tearDown(self):
            pass
    
        def get_app(self):
            return Application([('/rest/test/', AllServersHandler)])
    
        def test_server_status_with_advertiser(self):
            on_new_host(None, '127.0.0.1')
            response = self.fetch('/rest/test/', method='GET')
            result = json.loads(response.body, 'utf8').get('data')
            self.assertEquals(['127.0.0.1'], result)
    

    I’m not sure what damage this approach could introduce, so if someone else has a better suggestion, let me know!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running a Visual Studio Load Test using an Agent on one of
I've written an rspec test using Watir against a web application and it's running
We are using Team City and I noticed problem during running Watin test. Sometimes
In my jmeter test, I have a BSF PreProcessor step (using groovy) running before
In my C# program, I have a thread that represents a running test, which
I'm running a test, and found that the file doesn't actually get written until
I have an automated test running on my program that generates some large MPG
I have a set of Happstack.State MACID methods that I want to test using
I am running a selenium test using ruby and was wondering how I can
I am using JUnit 4.10 for running test suites, and I have implemented a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.