Quantcast
Channel: Active questions tagged retry-logic - Stack Overflow
Viewing all articles
Browse latest Browse all 950

I want to add retry logic and. refactor the code in the python socket connect code

$
0
0

I have the below Python code which checks whether the ssh host is up or not:

`for hostname ,ipaddr in host_dict.items():                   if tcp_conn.tcp_port_is_open(ipaddr, constants.TCP_PORT, constants.TCP_TIMEOUT) == True :                print("host is Up")                            else:                print("Host is Down")`

I want to add retry logic which checks if the host is having some issue then it reconnects and checks whether it is up or not, the retry count will be 3.

I tried running the code and it works fine, but i want to add the retry logic in case the host is down or having some issues then retry should try to connect again with the host.


Viewing all articles
Browse latest Browse all 950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>