def getpid(self): """Get the process id for this instance by reading its pid file. Returns :const:`None` if the pid file does not exist. """ return platforms.PIDFile(self.pidfile.replace('%n', self.name)).read_pid()
def getpids(self, p, cmd, callback=None): from celery import platforms pidfile_template = p.options.setdefault("--pidfile", "celeryd@%n.pid") nodes = [] for nodename, argv, expander in multi_args(p, cmd): pidfile = expander(pidfile_template) try: pid = platforms.PIDFile(pidfile).read_pid() except ValueError: pass if pid: nodes.append((nodename, tuple(argv), pid)) else: self.note("> %s: %s" % (nodename, self.DOWN)) if callback: callback(nodename, argv, pid) return nodes