socket: Too many open files
> out = commands.getstatusoutput('traceroute ' + ip)
describes subprocess.getstatusoutput as one of the "legacy functions from the 2.x commands module. These operations implicitly invoke the system shell and none of the guarantees described above regarding security and exception handling consistency are valid for these functions."
I suggest you use subprocess.run or Popen.communicate instead. Once you've done that, perhaps your problem will go away.
And even if it does not, I think you're better placed for getting support, when you're not using legacy commands.
I hope this helps, and good luck.