When I am running CherryPy Hello World:
import cherrypy
class HelloWorld:
def index(self):
return \"Hello world!\"
index.exposed = True
che
If you are trying to deploy CherryPy on Heroku, where you cannot use the loopback to check whether you have really opened a port, then you need to simply disable CherryPy's wait_for_occupied_port()
function so that CherryPy's self-consistency check does not decide that it has, in fact, failed to start. Here are the three lines that I use to fix CherryPy so that it runs on Heroku:
from cherrypy.process import servers
def fake_wait_for_occupied_port(host, port): return
servers.wait_for_occupied_port = fake_wait_for_occupied_port
If you get a python exception printed to stdio that 8080 is not free on 127.0.0.1, then what you do is this:
netstat -o -a
at the windows command prompt. Doing netstat -o
alone will give you an incorrect PID.
Look for 8080 in the address string in the first column. Once found, go horizontally over to the last column which is the PID (process ID).
Now to kill a process, I use kill <PID>
which is part of an mysys install. I found that out by doing where kill
on my system.
Thus all together:
netstat -o -a
[find PID then hit ctrl-c to stop netstat]
kill 13164
where 13164 is an example PID found in the first step.
If you do not have mysys installed, then install it or else look up how to kill a process by its PID on windows.
I think I had a similar problem when I started using CherryPy... But I can't remember exactly what it was... But the fix involved using a config file instead of passing the configs by hand:
MyProj.conf:
[global] server.socket_host = "127.0.0.1" server.socket_port = 8080 server.thread_pool = 10
MyProj.py
import os
import cherrypy
class HelloWorld:
def index(self):
return "Hello world!"
index.exposed = True
# Assumes the config file is in the directory as the source.
conf_path = os.path.dirname(os.path.abspath(__file__))
conf_path = os.path.join(conf_path, "MyProj.conf")
cherrypy.config.update(conf_path)
cherrypy.quickstart(HelloWorld())
This definitely works here.
I'm using Python 2.6.1 and CherryPy 3.1.1 and I run the script with -W ignore
:
c:\My_path> python -W ignore MyProj.py
If you're under *nix, you should put the -W ignore
in the #!
comment at the top of the file.
If you're on OS X, try calling:
sudo lsof -i :8080
which will tell you the process using that port.
You've probably got something else listening on that port.
On Linux do:
netstat -pnl | grep 8080
And see what process is listening on 8080
On Windows use something like TCPView to do the same.
As Jason R. Coombs wrote there is a problem with disabled loopback device. heroku.com has loopback disabled therefore CherryPy will crash. I filed a bug for this.
Update: Reported as resolved.