How robust is Python ?
Sandipan Gangopadhyay
sandipan at vsnl.com
Fri Jan 12 12:12:38 EST 2001
"Steve Holden" <sholden at holdenweb.com> wrote in message
news:D%F76.7503$6i.96299 at e420r-atl2.usenetserver.com...
> "Sandipan Gangopadhyay" <sandipan at vsnl.com> wrote in message
> news:mailman.979313781.1111.python-list at python.org...
> >
> > ----- Original Message -----
> > From: "Moshe Zadka" <moshez at zadka.site.co.il>
> > To: <rturpin at my-deja.com>
> > Cc: <python-list at python.org>
> > Sent: Saturday, January 06, 2001 4:09 PM
> > Subject: Re: How robust is Python ?
> >
> > > On Fri, 05 Jan 2001, rturpin at my-deja.com wrote:
> > >
> > > > Unfortunately, cron is not cross-platform. We'll have
> > > > some sort of mechanism to do this. The problem is not
> > > > just the language and operating system, but everything
> > > > that can kill a process. Still .. you want such mechanism
> > > > as backup, not as a solution to regular crashes.
> > >
> > > Of course. None of this is meant to imply Python crashes regularily.
> > > In fact, I can't think off-hand of a language less likely to suffer
> > > crashes, given that you take a few exception-catching precautions
> > > in the main loop (have a catch-all except: which re-execs the
process).
> >
> > I want this in my code, but came across a problem -
> >
> > while binAliveMarker:
> > if binIWannaStartAgain:
> > time.sleep(1)
> > continue
> > work code ...
> >
> > If I try a catch-all except, continue hits except on the outer level
> rather
> > than while. Probably the reason that it results in syntax error.
> >
> > while binAliveMarker:
> > try:
> > if binWannaStartAgainLater:
> > time.sleep(1)
> > continue
> > work code ...
> > except:
> > pass
> >
> > Any suggestions to make it work with continue (or an alternative) ?
Apart
> > from removing continue completely by making the work code inside an else
?
> >
> > Thanks,
> >
> > Sandipan
> >
> The documentation states that the continue syntax error is due to
"laziness"
> on the part of the implementors, though they seem to keep pretty busy to
me.
> You can work around this with:
>
> class Continue:
> pass
>
> while binAliveMarker:
> try:
> if binWannaStartAgainLater:
> time.sleep(1)
> raise Continue
> work code ...
> except Continue:
> continue
>
Have I done something illogical here ?
Changes in order to have non-selective except.
class ContinueThroughExcept:
pass
while binAliveMarker:
try:
if binWannaStartAgainLater:
time.sleep(1)
raise ContinueThroughExcept
work code ...
except ContinueThroughExcept:
continue
except:
pass
> You could maybe leave the "pass" you had in the except rather than
changing
> it to continue, but it's never a good idea to include non-selective except
> clauses: they catch KeyboardInterrupt, among other nasties you probably
> really want to see.
I agree. In my case however, that is a boon. There wont be anyone there to
see the nasties and might add some of their own. Ie, I dont want
KeyboardInterrupt to interrupt the process anyway. I want that loop up
anyhow until binAliveMarker goes down.
>
> [Just passing along a wrinkle somebody else taught me...]
Thanks a lot.
>
> regards
> Steve
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list