Feature #340

Allow to postpone computation heavy processing after Skylark serves response

Added by Jan Dolinár over 11 years ago. Updated over 11 years ago.

Status:ApprovedStart date:10/20/2012
Priority:NormalDue date:
Assignee:Jan Dolinár% Done:


Category:Wpp (web framework)Spent time:-
Target version:-


It is quite common situation where user request can be answered quickly, but there is a lot of additional work that is not crucial for the response. E.g: user uploads a file, which is than processed. The server can respond as soon as the file is received and process the file later. This results in much better page performance perceived by the user.

In Skylark it is currently not possible to answer send the response until handler exits. For such cases, I propose to add a Callback to Http class that would be executed after the response is sent.

There are as usually other possible solutions, e.g. sending data as soon as they are passed to the Http (which would require omitting Content-Length header) or designing a queue of such post-processing requests that would be processed in dedicated thread(s). Compared to those, the Callback solution seems most elegant to me. Another solution could be to add a Flush or Send method to Http that would send all the data and then the postprocessing could take place right in the handler. But that would probably need significant changes. Besides, I really like that when using Callback multiple parts of the app that handle the request can add their request for post-processing using operator << and they will all be executed in due time.

If you decide to accept the patch, I'll fill in the documentation ;-)

Skylark.patch Magnifier (789 Bytes) Jan Dolinár, 10/20/2012 08:43 PM


#1 Updated by Miroslav Fidler over 11 years ago

  • Status changed from Patch ready to Ready for QA
  • Assignee changed from Miroslav Fidler to Jan Dolinár

This is a good idea, but after some thinking I have came to conclusion that callback is perhaps a little bit clumsy here. Instead, I have added "Finalize" method that can be called to send the response back. Please check...

#2 Updated by Jan Dolinár over 11 years ago

  • Status changed from Ready for QA to Approved

Also available in: Atom PDF