def spawn_collector(col):
 LOG.info('%s (interval=%d) needs to be spawned', col.name, col.interval)
 try:
  col.proc = subprocess.Popen(col.filename, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, preexec_fn=os.setsid)
 except OSError as e:
  LOG.error(('Failed to spawn collector %s: %s' % (col.filename, e)))
  return
 col.lastspawn = int(time.time())
 col.last_datapoint = col.lastspawn
 set_nonblocking(col.proc.stdout.fileno())
 set_nonblocking(col.proc.stderr.fileno())
 if (col.proc.pid > 0):
  col.dead = False
  LOG.info('spawned %s (pid=%d)', col.name, col.proc.pid)
  return
 LOG.error('failed to spawn collector: %s', col.filename)

def spawn_collector ( col ) : LOG . info ( '%s (interval=%d) needs to be spawned' , col . name , col . interval ) try : col . proc = subprocess . Popen ( col . filename , stdout = subprocess . PIPE , stderr = subprocess . PIPE , close_fds = True , preexec_fn = os . setsid ) except OSError as e : LOG . error ( ( 'Failed to spawn collector %s: %s' % ( col . filename , e ) ) ) return col . lastspawn = int ( time . time ( ) ) col . last_datapoint = col . lastspawn set_nonblocking ( col . proc . stdout . fileno ( ) ) set_nonblocking ( col . proc . stderr . fileno ( ) ) if ( col . proc . pid > 0 ) : col . dead = False LOG . info ( 'spawned %s (pid=%d)' , col . name , col . proc . pid ) return LOG . error ( 'failed to spawn collector: %s' , col . filename )
takes a collector object and creates a process for it .