List Info

Thread: Doing ressource intensive tasks in a CherryPy method




Doing ressource intensive tasks in a CherryPy method
user name
2006-02-06 21:46:30
Michael Goettsche wrote:
> On Monday 06 February 2006 21:41, Blake Winton wrote:
>>> The processing of a form will take
approximately 10 seconds.
>>> I don't want the user to see what's going on
and don't want him to have
>>> to wait until processing is done.
>>> So, I wonder how I can solve my problem as
CherryPy shows the return
>>> value of the method to the user and no further
processing is possible
>>> after 'return'ing a method.
>> You could use yield...
>>
>> See http://bwinton.latte.ca/Programming/cherry
Py/UpdateComics/ComicsApp.py
>> for a small example.
>>
>> Later,
>> Blake.
> 
> Interesting idea, thanks. So I could simply write:
> def index(self):
>     yield "Thanks for filling out the form
blablablablabla"
>     doRessourceIntensiveJob()
> 
> and the user would see the message immediately without
knowing that there is 
> further setup going on? Are there any possible side
effects in using this 
> approach?

Well, I think you have to explicitly turn on the following
config options:

     "server.protocolVersion":
"HTTP/1.1"
     "streamResponse": True

Otherwise, the entire body of the page handler is consumed
and then sent 
in the response.

I think there are some issues with CP only being
"conditionally" 
HTTP/1.1 compliant.  AFAIK, these problems are mitigated if
you run 
behind Apache and use it for serving static content.

What was your experience with it Blake?

Christian

Doing ressource intensive tasks in a CherryPy method
user name
2006-02-07 20:25:25
> I think there are some issues with CP only being
"conditionally"
> HTTP/1.1 compliant.  AFAIK, these problems are
mitigated if you run
> behind Apache and use it for serving static content.
>
> What was your experience with it Blake?

You know, it turned out that CherryPy allowed me to
restructure my app
so that more stuff was happening in parallel, and so I
didn't really
notice the lack of streaming.    I should
really turn that on
sometime and see if it improves the response time any
further.

Later,
Blake.
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )