My python script is (single threaded) running for many hours, however, after some time it suddenly stops. We used a try-except
block to debug the error. However, this behaves very strange. We use:
try:
while True:
# do routine
time.sleep(someSeconds)
except Exception as e:
# exception!
finally:
# finish
The while routine is executing normally, then the script (aka main thread) falls asleep, wakes up and executes the routine again. After hours the finally block gets executed, without the exception block being executed (first).
How can this be? As far as I know, when the while True
loop stops for any reason, the except block should be executed (before finally)? How can it be that the error is not caught?
Note: there is no return/ break in the while loop