How to close a cherry server?

im on win7, I started the helloworld.py tutorial and everything is fine, but I don’t know how to exit the service. I use

quit()

but an error message appears on the command line and the exit.but service is still running and takes my port 8080. I did not find a way to manually disable it.

  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'
+5
source share
2 answers

According to this page , quit()it is not suitable for this task.

Depending on how you start your server, you should use 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.
+4
source

Include this in your python file.

@cherrypy.expose

def shutdown(self):  
    cherrypy.engine.exit()

Then add a link to your page.

<a id="shutdown"; href="./shutdown">Shutdown Server</a>
+4
source

All Articles