Exemplo n.º 1
0
 def pub(self, k, **args):
     if k not in self.registered:
         logger.warning('Call on a pub on a unregistered key %s' % k)
         return
     l = self.registered[k]
     for f in l:
         f(**args)
Exemplo n.º 2
0
    def check_parallel_run(self):
        # TODO: other daemon run on nt
        if os.name == 'nt':
            logger.warning("The parallel daemon check is not available on nt")
            self.open_pidfile(write=True)
            return

        # First open the pid file in open mode
        self.open_pidfile()
        try:
            buf = self.fpid.readline().strip(' \r\n')
            if not buf: # pid file was void, cool
                return
            pid = int(buf)
        except Exception as err:
            logger.info("Stale pidfile exists at %s (%s). Reusing it." % (err, self.lock_path))
            return

        try:
            os.kill(pid, 0)
        except Exception as err: # consider any exception as a stale pidfile.
            # this includes :
            #  * PermissionError when a process with same pid exists but is executed by another user.
            #  * ProcessLookupError: [Errno 3] No such process.
            logger.info("Stale pidfile exists (%s), Reusing it." % err)
            return

        logger.error("Valid previous daemon exists (pid=%s) Exiting." % pid)
        raise SystemExit(2)
Exemplo n.º 3
0
 def launch(self):
     if not Client:
         logger.warning('Missing docker lib')
         return
     t = threader.create_and_launch(self.do_loop, name='docker-loop')