Paul Moore wrote:
> I'd like to run the CherryPy WSGI server as a Windows
service.
> I tried tweaking the usual code for putting CherryPy
into a
> service, but I got an error:
>
> <class 'exceptions.TypeError'>: start() got an
unexpected keyword
> argument 'init_only'
>
> This looks like the WSGI server doesn't have the same
interface
> as the standard CherryPy server.
There's an unfortunate terminology conflict, here. The WSGI
server *is*
the standard CherryPy *HTTP* server. CherryPy also has an
"app server"
layer on top of that, which is what gets invoked when you
call
cherrypy.server.start(). The _cpwsgi module (app server
layer) wraps the
_cpwsgiserver module (HTTP server layer) for CP, so if you
only import
_cpwsgiserver, you don't get the same interface at all.
> This impression is reinforced by the fact that when
running from
> the console (no service code) CherryPyWSGIServer
doesn't handle
> Ctrl-C properly (by stopping), where the normal CP
server does
> - my naive assumption was that the two servers shared a
lot of
> code, so things like this should be the same.
There's a comment in the source code about the Ctrl-C
issue:
# We don't have to trap KeyboardInterrupt or
SystemExit here,
# because cherrpy.server already does so, calling
self.stop()
for us.
# If you're using this server with another
framework, you should
# trap those exceptions in whatever code block calls
start().
Again, it's terminology. The Ctrl-C handling is done at the
"app server"
layer, not the HTTP server layer.
> My non-service code looks like this:
>
> from cherrypy._cpwsgiserver import CherryPyWSGIServer
> from wsgi_sample import simple_app
>
> server = CherryPyWSGIServer(('', 8888), simple_app)
> server.start()
>
> Am I using CherryPyWSGIServer correctly? (I can post
the service code
> if necessary, but it's a lot longer because of the
service
> boilerplate).
This code uses _cpwsgiserver correctly, yes. Note that
CherryPyWSGIServer.start takes no arguments (unlike
cherrypy.server.start, which among others takes an
"init_only"
argument).
So the solution depends on which layer(s) you want to wrap
in a service.
Just the non-CP-specific _cpwsgiserver? Or a full instance
of
CherryPy-the-app-framework?
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|