Return results immediately but continue processing
Hello, I have an app that uses Zope as a Front-End for some Database queries, some of which require a long time to process. Is it possible to return an immediate result to the browser, something that says "Your processing request was received" and then *still* continue processing the query in the background until it completes? Thanks, VanL
Read the answer to the today's post "MessageDialog in Python Script". You may also find useful this how-to: http://www.zope.org/Members/don/long_procces Ausum ----- Original Message ----- From: "VanL" <vlindberg@verio.net> To: <zope@zope.org> Sent: Monday, December 02, 2002 5:03 PM Subject: [Zope] Return results immediately but continue processing
Hello,
I have an app that uses Zope as a Front-End for some Database queries, some of which require a long time to process.
Is it possible to return an immediate result to the browser, something that says "Your processing request was received" and then *still* continue processing the query in the background until it completes?
Thanks,
VanL
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Mon, 2002-12-02 at 23:50, Ausum Studio wrote:
Read the answer to the today's post "MessageDialog in Python Script". You may also find useful this how-to: http://www.zope.org/Members/don/long_procces
I've read this howto and it seems quite simple... But what does happens if the user cancel the request on his browser during this long-time process ?? - does the process goes until the end or is it cancelled immediately ? - in the first case, is there any way to check that the operation has been cancelled by the browser, so that the operation can be stopped ? Thanks for these informations. Thierry
Thierry Florac writes:
On Mon, 2002-12-02 at 23:50, Ausum Studio wrote:
Read the answer to the today's post "MessageDialog in Python Script". You may also find useful this how-to: http://www.zope.org/Members/don/long_procces
I've read this howto and it seems quite simple... But what does happens if the user cancel the request on his browser during this long-time process ?? - does the process goes until the end or is it cancelled immediately ? It goes until the end
- in the first case, is there any way to check that the operation has been cancelled by the browser, so that the operation can be stopped ? This might be possible:
Zope uses the "Medusa" framework to implement its servers. Medusa communicates with the client via channels. When the browser cancels the request, the channel is closed. In principle this can trigger some action although I doubt that it does currently. It may also be possible to directly check the channel state in the request. The "RESPONSE" object has a connection to the channel with high probability. Start your exploration there. Dieter
Dieter Maurer wrote: [About finding out if the client closes the connection ...]
The "RESPONSE" object has a connection to the channel with high probability. Start your exploration there.
Totally guessing here, but maybe it's worth trying if RESPONSE.write() throws an exception if the connection is closed. If not, it should. cheers, oliver
Oliver Bleutgen writes:
Dieter Maurer wrote: [About finding out if the client closes the connection ...]
The "RESPONSE" object has a connection to the channel with high probability. Start your exploration there.
Totally guessing here, but maybe it's worth trying if RESPONSE.write() throws an exception if the connection is closed. I would not expect it.
The medusa thread controlling the channel and the Zope "worker" thread are decoupled by a so called "producer". "write" appends to the producer.
If not, it should. Maybe, but
"RESPONSE.write" is (should be) used only in exceptional cases. You want an additional way to signal the worker thread that what it does in no longer of interest. Some flag, it may check or (even better) an appropriate signal (which formerly was delivered only to the main thread but now might also be delivered to other threads (when I understood this correctly)). Dieter
VanL wrote:
Is it possible to return an immediate result to the browser, something that says "Your processing request was received" and then *still* continue processing the query in the background until it completes?
ZopeHelp says: API Documentation class Response The Response object represents the response to a Zope request. Methods ... write(data): Return data as a stream HTML data may be returned using a stream-oriented interface. This allows the browser to display partial results while computation of a response to proceed. The published object should first set any output headers or cookies on the response object. Note that published objects must not generate any errors after beginning stream-oriented output. Permission Always available -mj
participants (6)
-
Ausum Studio -
Dieter Maurer -
Maik Jablonski -
Oliver Bleutgen -
Thierry Florac -
VanL