Search code examples
pythoncherrypy

how to shut down cherrypy server?


im on win7 ,i started a tutorial helloworld.py and everything doing fine but i don't know how to quit the service.i use

quit()

but command line give me an error message and exit.but service is still running and take my 8080 port. i hadn't find a way to shut down it manually.

  File "C:\python32\lib\site-packages\cherrypy\process\wspbus.py", line 197, in
publish
    output.append(listener(*args, **kwargs))
  File "C:\python32\lib\site-packages\cherrypy\_cpserver.py", line 151, in start

    ServerAdapter.start(self)
  File "C:\python32\lib\site-packages\cherrypy\process\servers.py", line 167, in
 start
    wait_for_free_port(*self.bind_addr)
  File "C:\python32\lib\site-packages\cherrypy\process\servers.py", line 410, in
 wait_for_free_port
    raise IOError("Port %r not free on %r" % (port, host))
IOError: Port 8080 not free on '0.0.0.0'

Solution

  • According to this page, quit() is not appropriate for this task.

    Depending on how you run your server, you should consider using cherrypy.engine.exit:

    >>> help(cherrypy.engine.exit)
    exit(self) method of cherrypy.process.win32.Win32Bus instance
        Stop all services and prepare to exit the process.