This requires encapsulating a framework, however any errors you describe continue to run. This requirement is that you assume that even if there is an error, it will not affect the running results of the program. This means that you can control the scope of the error yourself. If the probability of such an error is high and it is not fatal, you hope to pass it on the main The thread captures and any exception is eventually thrown through the program entry. So you should do the capture in the program run startup block.
try:
main()
except:
pass
This method will also exit when an exception occurs, if you want to continue trying. You can add a loop
while time_out < max_time_out:
try:
main()
except:
pass
timeout+=100
But this method requires you to know very well that the program will work normally after several attempts, otherwise it will still exit. Finally, what I want to say is that when the program hangs due to an exception, it reminds you that you really should fix it instead of ignoring it. If you ignore it and you can continue to run but it will bring wrong results, you will regret it~
In addition, if you add try..except in the outermost layer, when the program makes an error, it will only catch the error in the outermost layer, and then exit. I have a way, but after an error, you can only start over (it is best to find the error) place)
This requires encapsulating a framework, however any errors you describe continue to run. This requirement is that you assume that even if there is an error, it will not affect the running results of the program. This means that you can control the scope of the error yourself. If the probability of such an error is high and it is not fatal, you hope to pass it on the main The thread captures and any exception is eventually thrown through the program entry. So you should do the capture in the program run startup block.
This method will also exit when an exception occurs, if you want to continue trying. You can add a loop
But this method requires you to know very well that the program will work normally after several attempts, otherwise it will still exit.
Finally, what I want to say is that when the program hangs due to an exception, it reminds you that you really should fix it instead of ignoring it. If you ignore it and you can continue to run but it will bring wrong results, you will regret it~
should be
In addition, if you add try..except in the outermost layer, when the program makes an error, it will only catch the error in the outermost layer, and then exit. I have a way, but after an error, you can only start over (it is best to find the error) place)