(runnable, daemon, pidfile)
Run runnable class, possibly daemonized, locked on pidfile.
Run runnable class, possibly daemonized, locked on pidfile.
Run runnable class possibly daemonized locked on pidfile .
def run_single_process(runnable, daemon, pidfile):
    """Run runnable class, possibly daemonized, locked on pidfile."""

    # check if another process is running
    if pidfile and os.path.isfile(pidfile):
        if skytools.signal_pidfile(pidfile, 0):
            print("Pidfile exists, another process running?")
            sys.exit(1)
        else:
            print("Ignoring stale pidfile")

    # daemonize if needed
    if daemon:
        daemonize()

    # clean only own pidfile
    own_pidfile = False

    try:
        if pidfile:
            data = str(os.getpid())
            skytools.write_atomic(pidfile, data)
            own_pidfile = True

        runnable.run()
    finally:
        if own_pidfile:
            try:
                os.remove(pidfile)
            except: pass
def run_single_process ( runnable , daemon , pidfile ) : # check if another process is running if pidfile and os . path . isfile ( pidfile ) : if skytools . signal_pidfile ( pidfile , 0 ) : print ( "Pidfile exists, another process running?" ) sys . exit ( 1 ) else : print ( "Ignoring stale pidfile" ) # daemonize if needed if daemon : daemonize ( ) # clean only own pidfile own_pidfile = False try : if pidfile : data = str ( os . getpid ( ) ) skytools . write_atomic ( pidfile , data ) own_pidfile = True runnable . run ( ) finally : if own_pidfile : try : os . remove ( pidfile ) except : pass