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

Unable to run a simple tornado server #1014

Closed
harveypham opened this issue Aug 30, 2016 · 4 comments
Closed

Unable to run a simple tornado server #1014

harveypham opened this issue Aug 30, 2016 · 4 comments

Comments

@harveypham
Copy link

harveypham commented Aug 30, 2016

In bash shell, install python-pip:
sudo apt-get install python-pip

Install tornado:
sudo pip install tornado

Create a tornado server, server.py with the following content:

import tornado.ioloop
import tornado.web
ioloop = tornado.ioloop.IOLoop.instance()

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

if **name** == "**main**":
    application.listen(8888)

print 'starting'

try:
    ioloop.start()
except KeyboardInterrupt:
    print '^C pressed'
finally:
    print 'done'

Run the server:
sudo python server.py

  • Expected results
    The server starts and waiting for connection
  • Actual results (with terminal output if applicable)

Traceback (most recent call last):
File "server.py", line 15, in
application.listen(8888)
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1850, in listen
server.listen(port, address)
File "/usr/local/lib/python2.7/dist-packages/tornado/tcpserver.py", line 126, in listen
sockets = bind_sockets(port, address=address)
File "/usr/local/lib/python2.7/dist-packages/tornado/netutil.py", line 194, in bind_sockets
sock.bind(sockaddr)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use

(Note that socket 8888 is not used)

@sunilmut
Copy link
Member

This is quite likely related to #996. If you take a strace strace -o <strace_file> -ff <cmd> and share out the <strace_file>, I am happy to take a look and confirm.

And, thanks for trying out WSL!

@harveypham
Copy link
Author

strace attached. Thank you for taking time looking into this.

strace.71.txt

@zhwei820
Copy link

temperory solution:

change : tornado\netutil.py
line 111: def bind_sockets(port, address=None, family=socket.AF_UNSPEC,

to def bind_sockets(port, address=None, family=socket.AF_INET,

@benhillis
Copy link
Member

I am no longer hitting this issue on 1803. Please reopen if you continue to have issues.

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

4 participants