示例#1
0
    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)
示例#2
0
 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)
示例#3
0
    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