[Tutor] Restarting a module

Alan Gauld alan.gauld at btinternet.com
Mon Jul 23 19:52:55 CEST 2007


"Tino Dai" <tinoloc at gmail.com> wrote

> Sorry about that. I think that a simpler question would be:

I'm not sure what the better question is, but I think I
answered it :-)

> In my driver code:
>
>  ap = apacheModule.apacheModule(configXML)
>  while 1:
>       try:
>          rVs=ap.perf()
>          for anObj in self.objList:
>               getattr(anObj,"do")(rVs)
>          time.sleep(1)
>        except ArraryOutOfBoundsException:
>          pass
>       except Exception, e:
>          sys.stdout.write(str(e) + "\n")
>          sys.exit(1)
>
>
> And in my apacheModule class:
>
>         try:
> 
> (totalAccess,totalTraffic)=(rVs[3][1],self.sizeConvert ...
>         except Exception,e:
>                datetime.datetime.now()
>                sys.stdout.write(str(e) + "\n")
>                sys.stdout.write(rVs)
>
> If the apacheModule raises an ArrayOutOfBound exception (don't
> remember if that the real exception name), the exception will bubble 
> up, and
> the apacheDriver try-except will catch it, right?

No, if you catch it here, as you will if you catch all Exceptions, 
then
it will stop right there unless you explicitly raise it. You bneed to 
add a
raise statement after the stdout.write stuff.

Alan G. 




More information about the Tutor mailing list