An interruption ip camera / soft

hello, please
An interruption of comm. with the ip camera should not crash the program, How i cann do this please, i use jetson nano, python
In the event of loss of communication with the camera, the program must attempt to reconnect every 10 seconds, then resume processing.

Please have much detail information and reproduce step.


thank you for your answer, my goal is that when the IP camera disconnects (saying power problem) my software does not hang and it will wait a few minutes when the IP camera reconnects the software of the same is restarted

thank you