Length Processing

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Length Processing

Tim Roberts
I'm migrating a Python CGI-based web app to CherryPy.  One part of the app needs to do processing that could take several minutes.  With CGI, I forked a separate process and closed the stdin/stdout handles; that was sufficient to tell Apache to send the completed page to the client, but still allow my processing to continue.

How can I accomplish the same thing in CherryPy?  I could use subprocess to launch a separate process, but there's a lot of state to transmit.
-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Length Processing

Sylvain Hellegouarch

> I'm migrating a Python CGI-based web app to CherryPy.  One part of the
> app needs to do processing that could take several minutes.  With CGI, I
> forked a separate process and closed the stdin/stdout handles; that was
> sufficient to tell Apache to send the completed page to the client, but
> still allow my processing to continue.
>
> How can I accomplish the same thing in CherryPy?  I could use subprocess
> to launch a separate process, but there's a lot of state to transmit.

Maybe start a separate thread instead of a process. Then use a 202
Accepted in the main thread to inform the client the processing is
undertaken but not completed.

- Sylvain
>
> --
> Tim Roberts, [hidden email]
> Providenza & Boekelheide, Inc.
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Length Processing

Tim Roberts
Sylvain Hellegouarch wrote:
I'm migrating a Python CGI-based web app to CherryPy.  One part of the
app needs to do processing that could take several minutes.  With CGI, I
forked a separate process and closed the stdin/stdout handles; that was
sufficient to tell Apache to send the completed page to the client, but
still allow my processing to continue.

How can I accomplish the same thing in CherryPy?  I could use subprocess
to launch a separate process, but there's a lot of state to transmit.
    

Maybe start a separate thread instead of a process.

Hmmm, is that enough?  I can handle that.  I'll give it a try.  It didn't work in CGI because the threads shared handles, and Apache uses the stdin/stdout handles to decide when the page is complete.

Then use a 202 Accepted in the main thread to inform the client the processing is
undertaken but not completed.
  

The client doesn't have to wait.  The situation is that I occasionally have to send an e-mail to a thousand addresses.  The client triggers the action, but doesn't need a confirmation when complete.  I just need to do the work.
-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Length Processing

Robert Brewer
In reply to this post by Tim Roberts

Tim Roberts wrote:
> It didn't work in CGI because the threads shared handles,
> and Apache uses the stdin/stdout handles to decide when
> the page is complete.

CherryPy doesn't use stdin/out (it reads/writes from the socket), so no
worries there.

> > Then use a 202 Accepted in the main thread to inform the
> > client the processing is undertaken but not completed.
>
> The client doesn't have to wait.  The situation is that I
> occasionally have to send an e-mail to a thousand addresses.
> The client triggers the action, but doesn't need a confirmation
> when complete.  I just need to do the work.

Sylvain is right; that's exactly what 202 was designed for.


Robert Brewer
System Architect
Amor Ministries
[hidden email]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---