Example #1
0
    def work(self, interval=5):
        self.register_worker()
        self._register_signal_handlers()
        
        util.setprocname("monque: Starting")
        
        try:
            while not self._shutdown_status:
                worked = self._work_once()

                if interval == 0:
                    break

                if not worked:
                    util.setprocname("monque: Waiting on queues: {0}".format(','.join(self._queues)))
                    time.sleep(interval)
        finally:
            self.unregister_worker()
Example #2
0
    def process(self, order):
        if self._dispatcher == "fork":
            child = self._child = multiprocessing.Process(target=self._process_target, args=(order,))
            self._child.start()

            util.setprocname("monque: Forked {0} at {1}".format(self._child.pid, time.time()))

            while True:
                try:
                    child.join()
                except OSError, e:
                    if 'Interrupted system call' not in e:
                        raise
                    continue
                break

            self._child = None

            if child.exitcode != 0:
                raise Exception("Job failed with exit code {0}".format(child.exitcode))
Example #3
0
 def dispatch(self, order):
     util.setprocname("monque: Processing {0} since {1}".format(order.queue, time.time()))
     order.job.run()