Fwd: socket: Too many open files

Shakti Kumar shakti.shrivastava13 at gmail.com
Sat Oct 13 04:48:29 EDT 2018


>Hello,
>I’m running a script which basically does a traceroute to the list of
hosts provided, and then pulls up some info by logging in to gateways in
the path.
>I am running this script for a list of almost 40k hosts in our data
centers.
>Also, I am using commands module to get the traceroute output.

>out = commands.getstatusoutput('traceroute ' + ip)

>However I observe that this particular line is failing with socket error
after I reach some 5k to 6k hosts.
>I know commands module is using pipes to execute the given command and
this is one reason for exhaustion of file descriptors.
>Any suggestions for improving this and getting a workaround?

>Thanks,
>Shakti

I dont understand how I should close the socket created by commands module
after I do traceroute to one host.
Also, if I’m not wrong, isn’t commands module supposed to do that on its
own?



More information about the Python-list mailing list