3 ms·
Yes. This is why you should always use context managers and finally blocks in languages with exceptions. Always assume that anything can fail at any time and ac
by Too 2y ago
Yes. This is why you should always use context managers and finally blocks in languages with exceptions. Always assume that anything can fail at any time and accept that not everything can nor should be recovered from.
On the other end of the spectrum you have go, where in fact every line does need to have their error conditions explicitly checked. How do they handle this situation?
What is dangerous with finally-blocks is if they start consuming a lot of time, such that the timeout interruption itself makes the timeout miss its deadline. Usually you need 2 timeouts, one for the main operation and a second for the cleanup.