[Tutor] Is there a 'hook' to capture all exits from a python program?
Alan Gauld
alan.gauld at btinternet.com
Thu Mar 19 02:07:13 CET 2015
On 18/03/15 23:55, Steven D'Aprano wrote:
>> You don't say what your environment is but you should be aware
>> that Python is not really a suitable tool for real time
>> programming, especially if it safety critical.
> I wouldn't want to use Python to control the critical parts of a nuclear
> reactor or a plane's autopilot, but people use it to control mechanical
> devices in near-real-time.
Yes, and that's the crux. Near real-time is fine, especially if
nobody will die.
> comp.lang.python newsgroup who (I think) uses Python to drive some sort
> of circuit board mechanical etching machine.
>
> Using Python to control (say) an Arduino is pretty popular too.
Yes, I use Python on my Raspberry Pi and on an Arduino, it's fine for
that kind of thing. (Actually the Arduino can do real real-time stuff,
but the Pi can't.)
My concern was the OPs comment that:
" I must turn off that relay or harm may occur."
Now if the 'harm' is just a mucked up circuit board it's not such
a big deal.
But, if its a flooded field, a damaged machine costing $100Ks or even a
person's life then it's important to point out that python may not
be the tool of choice!
Similarly, if the time to turn it off is more than a second, say,
its not an issue. But if its less than a couple of milliseconds
then I'd be worried.
Maybe I spent too many years designing hard-real-time safety
critical systems. But a little bell always goes off in my head
when I read stuff like "...or harm may occur"
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list