<br>Hi,<br><br>It is more complicated than that though<br><br>Here is the entry point which is a method of my application<br><br>from webob import Request, Response, exc<br>class WebNoteApp(object):<br><br>def __call__(self, environ, start_response):<br>
<br>      req = Request(environ)<br>      req.charset = 'utf8' # Force to use Unicode<br>      action = req.params.get('action', 'show_frontpage')<br>      if ( req.cookies.get('authenticated', '0') == '0' and action != 'do_login' ):<br>
        action = 'show_login'<br>      try:<br>          try:<br>              #meth = getattr(self, 'action_%s_%s' % (str(action), req.method) )<br>              meth = getattr(self, 'action_%s' % str(action)  )<br>
          except AttributeError:<br>              raise exc.HTTPBadRequest('No such action %r' % action).exception<br>          <span style="background-color: rgb(255, 255, 153);">resp = meth(req)</span><br>      except exc.HTTPException, e:<br>
          resp = e<br>      return resp(environ, start_response)<br><br>##<br><br>As you can see the method call is already in try: except - I do not process if it failed yet but seems it just bomb out with 500 rather than going into the code res = e<br>
<br>the meth (not listed here) will call a model object and model contains several Storm objects. I even try to reload the model in the __init__ of the Webnote class but it is still flaky, it work , sometimes it work some time got error but reload will work (improvement compared with before that it never recover until restart apache). <br>
<br>For now the most reliable way is cgi with slowness.<br><br><br><br><br><div class="gmail_quote">On Wed, Jan 26, 2011 at 9:20 PM, Jamu Kakar <span dir="ltr"><<a href="mailto:jkakar@kakar.ca">jkakar@kakar.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi Steve,<br>
<div class="im"><br>
On Wed, Jan 26, 2011 at 10:00 AM, Steve Kieu <<a href="mailto:msh.computing@gmail.com">msh.computing@gmail.com</a>> wrote:<br>
> Thanks for the answer.<br>
><br>
> The problem is that when create a Store object, storm does not try to<br>
> connect right away so no exception is thrown at that point. When there is a<br>
> need, storm try to use the connection and fail. To handle it, I have to wrap<br>
> many try: catch exception all over places and not quite sure where and it<br>
> does not look good.<br>
<br>
</div>In most cases you need one try/except at the place where you<br>
application starts processing the request.  Something like:<br>
<br>
def receive_request_from_web_server(request, retries=3):<br>
    try:<br>
        handle_request(request)<br>
    except DisconnectionError:<br>
        if retries:<br>
            # Probably want to sleep for a few seconds here, to give<br>
            # the database a chance to recover<br>
            receive_request_from_web_server(request, retries - 1)<br>
        else:<br>
            raise<br>
<br>
def handle_request(request):<br>
    # Application logic for the request<br>
<div class="im"><br>
> Like a php mysql db, they just don't care, if connection goes away, they<br>
> reconnect / make new connection automatically. That would be be nice<br>
<br>
</div>That's not really possible with transactions.  You need to start a new<br>
transaction and perform your operation from scratch.<br>
<br>
Thanks,<br>
<font color="#888888">J.<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Steve Kieu<br>