[Tutor] Restarting a module

Tino Dai tinoloc at gmail.com
Mon Jul 23 14:54:56 CEST 2007


Hi Everybody,

     I have a question about restarting a part of the program after it dies.
I have a driver program that instantiates a class and runs methods from that
class. Occasionally, the method gets bad data and it bombs out. Instead of
bombing out, I would like the program to grab new data and start the
processing. I already have the try except block ready, but I'm unsure about
how to restart the method itself. Is it just as easy as self.someMethod() or
do I need to do something to the namespace to insure that I don't get
leakage from the past running of the method.

Driver Section:
        ap=apacheModule.apacheModule(configXML,putInDB="1")
        while 1:
            rVs=ap.perf()
            for anObj in self.objList:

Class Section (apacheModule module):

        def perf(self):
           <..stuff deleted..>
           self.putMethod:
             # putMethod is a variable controlled by an XML file, assume
this is always true
              return self.put(self.parse(lines))
           else:
              return self.parse(lines)

         def put(self,rVs):
         <..stuff deleted>
             try:
                (totalAccess,totalTraffic)=(rVs[3][1],self.sizeConvert
(rVs[3][3],rVs[3][4]))

(userUsage,sysUsage,cuserUsage,csysUsage,cpuLoad)=(rVs[4][1],rVs[4][2],rVs[4][3],rVs[4][4],rVs[4][6])
                (requestsSec,bandwidth,perRequest)=(rVs[5][0],
self.sizeConvert(rVs[5][1],rVs[5][2]),self.sizeConvert(rVs[5][3],rVs[5][4]))
                (requestsProc,idle)=(rVs[6][0],rVs[6][1])
            except Exception,e:
                datetime.datetime.now()
                sys.stdout.write(str(e) + "\n")
                sys.stdout.write(rVs)
         <..stuff deleted..>


Thanks,
Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070723/4c20d03e/attachment.html 


More information about the Tutor mailing list