Re: What is the right way to do heavy operations on request?

David Allouche <[email protected]> Mon, 23 Oct 2017 16:29:37 +0200
Newsgroups gmane.comp.python.cherrypy
Message-ID <2d567386-e951-4740-9edb-4b285a3134e0@Spark>
The cherrypy web server is multithreaded. Each request is handled in a separate thread.

You might have an issue with the thread pool filling up. Older versions of cherrypy use a fixed size thread pool.

Generally, a plain http server like cherrypy should respond as quickly as possible. If the server side task can take a long time, you should use a background thread and have a client pool the server for the status of the task. You could also use websockets for efficient handling of long requests, but in this case you should use a websockets server like tornado.

On 20 Oct 2017, 21:53 +0200, Ilya Persky <[email protected]>, wrote:
> Hello!
>
> I'm writing a simple web app that needs to do some loooong (5 seconds or more) operation on each request it receives.
> Actually, it exposes a webhook and has to do a call to a slow external API whenever this webhook is triggered.
>
> AFAIU this can make the whole CherryPy server hang util the operation is complete.
>
> Am I wrong? How would I deal with situation like this? Can I use a multiprocessing safely with CherryPy or some other method may be?..
>
> Thank you!
> Ilya.
> --
> 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.

-- 
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.