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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Ilya Persky
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

David Allouche
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 <[hidden email]>, 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 [hidden email].
To post to this group, send email to [hidden email].
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.