def handle(self, *args, **options) -> None: job_name = options['job_name'] job_args = options['job_args'] if job_args: publish_message(job_name, *job_args) else: publish_message(job_name)
def publish(self, priority: int = 0) -> MessageLog: from carrot.utilities import publish_message kwargs = json.loads(self.content or '{}') if isinstance(kwargs, str): kwargs = {} return publish_message(self.task, *self.positional_arguments, priority=priority, queue=self.queue, exchange=self.exchange or '', routing_key=self.routing_key or self.queue, **kwargs)
def requeue(self) -> 'MessageLog': """ Sends a failed MessageLog back to the queue. The original MessageLog is deleted """ from carrot.utilities import publish_message msg = publish_message(self.task, *self.positionals, priority=self.priority, queue=self.queue, exchange=self.exchange, routing_key=self.routing_key, **self.keywords) if self.pk: self.delete() return msg