[Tutor] Is there a 'hook' to capture all exits from a python program?

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Mar 19 02:31:06 CET 2015


On 19/03/2015 01:07, Alan Gauld wrote:
> 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"
>
>

All depends on your definition of real time.  Most systems we usually 
mean pretty darn fast, but the control system for the rudder on a super 
tanker is real time but takes minutes for the command to change course 
to take effect.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list