def maintain_fail_mail(self): if TaskLock.is_duplicate(): logger.warning('Conflict task, abort now') return TaskLock.lock() logger.info('Starting maintain fail mail record...') record_queue = RecordQueue.objects.filter(sent=False) for item in record_queue: resend_fail_record(item) logger.info('Resend mail record %s to %s' % (item.record.title, item.user.email)) TaskLock.unlock() logger.info('Finished maintain fail mail record.')
def run(self): if TaskLock.is_duplicate(): logger.warning('Duplicate task, abort now') return TaskLock.lock() manager = PluginManager() manager.load_plugins() for plugin in manager.plugins: plugin_instance = plugin['class'](iden=plugin['iden'], dir=plugin['dir']) try: plugin_instance.process() except PluginRequestError: logger.warning('Cannot access plugin %s main url' % plugin['iden']) except Exception: logger.exception(u'Error when process plugin %s' % plugin['iden']) logger.info('Finished plugin %s' % plugin['iden']) TaskLock.unlock() logger.info('Successfully ran monitor')