0

One thread in my python program check CPU use, in big simplification it look like this:

import time
import commands
while 1:
    example=commands.getstatusoutput('iostat')
    time.sleep(1)

after few days of work, program stop working, because: "socket: too many open files" I use all PiD number

I know that i can change number in cat /proc/sys/fs/file-max, but i would like "reset" numer of PiD. It is possibile without reset of whole device?

Cierniostwor
  • 339
  • 2
  • 4
  • 15
  • 1
    `iostat` with no arguments runs continuously. Would you rather run `iostat 1 1`, which will run for a few seconds and then exit? – Mark Plotnick Jan 14 '19 at 15:03
  • That's as undesirable as spawning a `top` per second ... what are you trying to achieve, stress the machine? – tink Jan 14 '19 at 16:07

1 Answers1

1
import os
import signal

os.kill(pid, signal.SIGTERM) #or signal.SIGKILL 

you have to kill the processes...

WiseStrawberry
  • 317
  • 1
  • 4
  • 14