def enqueue(cls,taskinfo): queue = taskinfo.get('queue',None) if queue: cls.push(queue, taskinfo) logger.info("enqueued '%s' job on queue %s" % (str(taskinfo), queue)) else: logger.error("unable to enqueue job with class %s" % str(taskinfo))
def work(self): while True: if self._shutdown: logger.info('shutdown scheduled') break task = self.next_task() self.child = None if task: logger.debug('picked up job,job details: %s' % task) self.before_fork(task) self.child = os.fork() if self.child: logger.info('Forked %s at %s' % (self.child,datetime.datetime.now())) try: os.waitpid(self.child, 0) except OSError as ose: """???need to consider the system interrupt condition """ import errno if ose.errno != errno.EINTR: raise ose logger.debug('done waiting') else: logger.info('Processing %s since %s' % (task._queue, datetime.datetime.now())) self.after_fork(task) self.process(task) os._exit(0)