0

I wrote a python script in a Windows environment that goes through an list of IP addresses and connects to each IP one at a time using WMI to retrieve information. There is an issue where the connection with some of the IPs causes the script to hang (it just waits for a response from the server indefinitely and never timeout).

for ip in listofIPs: 
    performWork(ip) #hanging issue occurs within this function call

I've been trying to find a way to modify my code so that the function call is given exactly one minute to execute else terminate the function call and move on to the next IP in the list.

I did stumble upon a way to implement function timeout in a Linux environment but this is a rather lengthy script and I don't have the time to convert it over to Linux. I also came across some proposed Windows environment solutions but I couldn't get them to work. I've tried the following:

Timeout a python function in windows

and

Stop code after time period

I was hoping someone can offer other suggestions/methods of resolving this issue.

Thanks,

J

Jahaha
  • 29
  • 4

0 Answers0