A
A
Andrew2014-10-16 22:17:49
Python
Andrew, 2014-10-16 22:17:49

How to restart a python script?

The question is, is it possible, if an error occurs in the execution of the program, to start it again?
Example: an error occurred during the execution of the program, and accordingly we are informed about this that there is an error in such and such a place, in this situation is there a way to just start all over again?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladlen Grachev, 2014-10-16
@15megatonn

For example, in general terms, you can do something like this: take 'while True', inside this loop is the 'try' block, in which the body of the program, and in except throw 'continue'.

I
Igor, 2014-10-16
@merryjane

What you want is an ordinary watch dog.
You can, as above, throw everything into an endless loop.
You can use a third-party script that will monitor the process and pick it up if it has "fallen". You can also use ready-made solutions, for example, supervisord.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question