On Tuesday 18 December 2007 03:35:30 Uwe C. Schroeder wrote:
> Hi everyone,
>
> this may be a stupid question, but how does one execute a controller method
> on delay.
> This is the sceanrio:
>
> I have a controller method (exposed) which is called by a webservice from
> the outside. The webservice just "POST"'s a set of variables to this
> method. The method processes the variables and then the method returns -
> which results in a 200 resultcode to the webservice.
> So far so good. But now I need to POST a response to the webservice,
> verifying that I got their message. I can't do that in the controller
> method they call, because my POST has to happen AFTER the controller
> returns the 200 response. So I was thinking about using the scheduler to
> just schedule a call to some method which then will use urllib2 to assemble
> and send the appropriate response.
> However, the scheduler can only schedule recurring tasks, not a single
> delayed execution.
>
> Anyone got a nifty idea how to do this?
Who came up with this braindead RPC semantics? Communicating a returncode
after a returncode has been communicated... that's just crazy. How the hell
is your controller going to know if the return of the first call has already
been processed when it "commits" the call? Either it will occasionally fail
because it's to early, or you have to introduce overlong latencies - without
any guarantees of course...
The first course of action _should_ be to get rid of that crazy scheme...
If that's not going to happen, I'd simply go for a thread. You can create a
simple helper function like this:
def delayed_execution(f, delay=3.0):
def de():
time.sleep(delay)
f()
t = threading.Thread(target=de)
t.setDaemon(True)
t.start()
Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---