Re: server won't exit when a streaming connection is active
morecowbell <[email protected]> Mon, 19 Feb 2018 03:59:10 -0800 (PST)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
add an asyc signal handler. something lie this should work:
def sig_handler(signum, frame):
Stop() # your Stop() function
# register the handlers before you call your Start(), eg.:
signal.signal(signal.SIGUSR1, sign_handler)
signal.signal(signal.SIGUSR2, sign_handler)
check out https://pymotw.com/3/signal/index.html
On Sunday, February 18, 2018 at 9:42:31 AM UTC-8, Dereck wrote:
>
> Hi all, I am pretty new to cherrypy and have been playing around with it
> and ran into an issue. I have my server serving up a streaming response for
> mjpeg. It work wonderfully until I want to stop the server. It will not
> exit if there is an active connection. The output gets stuck at "Stopping
> Engine Bus". Is there a way to force the server to shutdown even if there
> are active connections. My code is as follows:
>
>
> class HelloWorld(object):
> @cherrypy.expose
> def index(self):
>
> cherrypy.response.headers['Content-Type']='multipart/x-mixed-replace;
> boundary=frame'
> def content():
> while True:
> yield (b'--frame\r\n'
> b'Content-Type: image/jpeg\r\n\r\n'+ frame +
> b'\r\n')
> return content()
> index._cp_config = {'response.stream': True}
>
>
> def Start():
> cherrypy.config.update({'server.socket_host': '0.0.0.0',
> 'server.socket_port': 9090})
> cherrypy.tree.mount(HelloWorld(),"/")
> cherrypy.engine.start()
>
>
> def Stop():
> cherrypy.engine.stop()
> cherrypy.engine.exit()
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.