>> When a request comes in a tg app will access all sorts of remote/local
>> services like db, etc. These might take very long to complete
>> occasionally due to high traffic, local disruptions, etc. and let's
>> suppose these disruptions are only temporary. So if they happen we
>> have every reason to believe that after a few seconds the services
>> will be available again.
>>
>> I'd like to have a general mechanism for handling this and returning a
>> short page to the user saying "services temporary unavailable, please
>> try again in a few moments". Since I wouldn't want to handle every
>> service separately I thought it would be handy to be able to say "if
>> the controller doesn't return the response dict in 5 seconds, let's
>> send the warning page". What would be the way to instruct tg 1.x to do
>> this? I thought about a decorator for the exposed methods, or are
>> there better solutions? Maybe others have already come up with
>> something better and/or more elegant.
>
> I doubt this can be done with "pure" TG1, as this is a concurrent thing to
> determine.

What do you mean by 'concurrent thing to determine'?

> The only option I see is to use a proxy that has a timeout when
> waiting for the socket to retrieve the downstream data, and then redirect to
> that page of yours.

I think it's possible to have a timeout decorator that will simply
count the given number of seconds and if that passes, abort the
callable. Whether the callable is busy with a socket or anything else,
is irrelevant.

I'm thinking along the lines of

http://code.activestate.com/recipes/307871/
http://pypi.python.org/pypi/timeout

which both only use the signal module to achieve this. I'm not very
familiar with this module so I'm not sure what the side effects are in
a multithreaded environment like wsgi/tg/apache/etc.

You think this would not work with tg 1.x in general?
Or you think that it would not work with some of the deployment
options in particular?

Cheers,
Daniel

> Under TG2, or if running TG1 below a WSGI-container, you might use WSGI to
> make an internal dispatch concurrently & then render the sorry-page. Not no
> nice of an setup though, and I don't know if you lose karma-points for
> making every request spawn an extra thread.


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to