CherryPy Hello World error

前端 未结 10 1050
广开言路
广开言路 2020-12-31 07:32

When I am running CherryPy Hello World:

import cherrypy

class HelloWorld:
    def index(self):
        return \"Hello world!\"
    index.exposed = True

che         


        
相关标签:
10条回答
  • 2020-12-31 08:20

    I had the same problem when running CherryPy 3.2.2 on my Win7 PC with Python 3.3 The server would start normally and then would crash in about a couple of minutes.

    I've applied the patch from CherryPy 3.2.3 laurasia mentioned. But it didn't help.

    So I had to comment out the lines raising the error at the very end of python\Lib\site-packages\cherrypy\process\servers.py to prevent the server from dying:

    ...
    #    if host == client_host(host):
    #        raise IOError("Port %r not bound on %r" % (port, host))
    ...
    
    0 讨论(0)
  • 2020-12-31 08:24

    I ran into this problem yesterday on an Ubuntu Linux server. I spent a couple of hours trying to track down the bug in the CherryPy code before I realized that the error message is very generic. It will give this error message even if the host doesn't own the IP address to which the server is attempting to bind. In my case, the loopback interface (lo, 127.0.0.1) was disabled. Thus, even if I set server.socket_host='0.0.0.0', the attempt to check the port, wait_for_occupied_port, would fail (as it assumes, reasonably, that the loopback interface is always available). After re-enabling the loopback interface, the CherryPy server would start up normally.

    Update: CherryPy 3.2.3 has a fix for this particular issue. Until 3.2.3 is released, development builds are available on the CherryPy project downloads.

    0 讨论(0)
  • 2020-12-31 08:27

    AVG Anti-Virus was causing this problem for me. Uninstalling AVG (far from ideal) did the trick. I suspect the link scanner that I couldn't disable.

    0 讨论(0)
  • 2020-12-31 08:28
    • Use it on different port (8000 for example)
    • Read about ConfigApi (once again)
    • Try latest version not 3.0
    • Also this can be caused by some Windows firewall (Eset smart security or maybe other). So just use it on different port.
    0 讨论(0)
提交回复
热议问题