Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

too many file descriptors in select() #1802

Closed
Wall-ee opened this issue Aug 18, 2016 · 3 comments
Closed

too many file descriptors in select() #1802

Wall-ee opened this issue Aug 18, 2016 · 3 comments

Comments

@Wall-ee
Copy link

Wall-ee commented Aug 18, 2016

problem:

too many file descriptors in select()

problem describe:

i use tornado as a http server and using the asynchronous/coroutine method.

code structer is like:

class RequestHandler:
 executor = ThreadPoolExecutor(8)
    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def post(self,*****):

     result = yield self.def1(*****)

     self.write(result)
     self.finish()

     @run_on_executor
     def def1(******):
           return result

and then we stress test the server capacity which make HTTP POST request 10 time per second.

after about 3 minutes: the server shut down and report:

too many file descriptors in select()

*** environment

OS: windows 10

python: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32

tornado: 4.2.1

@bdarnell
Copy link
Member

This is why windows is not a fully-supported platform for Tornado: the select system call is limited in the number of file descriptors it can handle, and windows doesn't have any better alternatives that we can use. You'll have to use linux or something from the bsd family to handle large numbers of connections.

@Wall-ee
Copy link
Author

Wall-ee commented Aug 19, 2016

ok,thanks a lot. but is there any solutions to close the connection manually in windows system? i tryied to use

self.self.on_connection_close()

or

self.on_finish()

behind the self.write

but still not working.

or windows system is really not a good options for the http server~~~

@bdarnell
Copy link
Member

Don't call any of the on_* methods yourself; they're for tornado to tell your application what's going on, not for you to control tornado.

I think what you want is to reduce the idle_connection_timeout parameter (of the HTTPServer constructor). It defaults to 3600 (an hour), but you probably want it to be very short. (or maybe pass no_keep_alive=True so that idle connections don't stick around at all)

Windows may be a good option for other HTTP server software, but it's not a good fit for Tornado. If you want to stick with windows, consider using aiohttp instead for a windows-friendly python server with similar properties to Tornado.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants