当前位置: 首页 > 工具软件 > async-profile > 使用案例 >

apply_async函数参数

白学
2023-12-01
    def apply_async(self, args=None, kwargs=None, task_id=None, producer=None,
                    link=None, link_error=None, shadow=None, **options):
        """Apply tasks asynchronously by sending a message.

        Arguments:
            args (Tuple): The positional arguments to pass on to the task.

            kwargs (Dict): The keyword arguments to pass on to the task.

            countdown (float): Number of seconds into the future that the
                task should execute.  Defaults to immediate execution.
			任务应该在未来执行的秒数。默认情况下是立即执行。
            eta (~datetime.datetime): Absolute time and date of when the task
                should be executed.  May not be specified if `countdown`
                is also supplied.
			任务执行的绝对时间和日期。如果还提供了“倒计时”,则可能不指定。
            expires (float, ~datetime.datetime): Datetime or
                seconds in the future for the task should expire.
                The task won't be executed after the expiration time.
		   任务未来的日期时间或秒应该过期。任务在过期后将不会执行。
            shadow (str): Override task name used in logs/monitoring.
                Default is retrieved from :meth:`shadow_name`.
			重写日志/监视中使用的任务名称。默认值是从:meth: ' shadow_name '检索的。
            connection (kombu.Connection): Re-use existing broker connection
                instead of acquiring one from the connection pool.
			重用现有的代理连接,而不是从连接池中获取一个。
            retry (bool): If enabled sending of the task message will be
                retried in the event of connection loss or failure.
                Default is taken from the :setting:`task_publish_retry`
                setting.  Note that you need to handle the
                producer/connection manually for this to work.
		如果启用,将在连接丢失或失败的情况下重试发送任务消息。默认值取自:setting: ' task_publish_retry '设置。注意,您需要手动处理生成器/连接,这样才能工作。
            retry_policy (Mapping): Override the retry policy used.
                See the :setting:`task_publish_retry_policy` setting.
			重写使用的重试策略。参见:设置:' task_publish_retry_policy '设置。
            queue (str, kombu.Queue): The queue to route the task to.
                This must be a key present in :setting:`task_queues`, or
                :setting:`task_create_missing_queues` must be
                enabled.  See :ref:`guide-routing` for more
                information.
		要将任务路由到的队列。这个键必须出现在:setting: ' task_queues '中,或者必须启用:setting: ' task_create_missing_queues '。参见:ref: ' guide-routing '获取更多信息。
            exchange (str, kombu.Exchange): Named custom exchange to send the
                task to.  Usually not used in combination with the ``queue``
                argument.
                要将任务发送到的命名自定义exchange。通常不与‘队列’参数一起使用。

            routing_key (str): Custom routing key used to route the task to a
                worker server.  If in combination with a ``queue`` argument
                only used to specify custom routing keys to topic exchanges.
	自定义路由键,用于将任务路由到工作服务器。如果与' ' queue ' '参数组合,则仅用于指定主题交换的自定义路由键。
            priority (int): The task priority, a number between 0 and 9.
                Defaults to the :attr:`priority` attribute.
			任务优先级,一个介于0和9之间的数字。默认为:attr: ' priority '属性。
            serializer (str): Serialization method to use.
                Can be `pickle`, `json`, `yaml`, `msgpack` or any custom
                serialization method that's been registered
                with :mod:`kombu.serialization.registry`.
                Defaults to the :attr:`serializer` attribute.
		要使用的序列化方法。可以是' pickle ', ' json ', ' yaml ', ' msgpack '或任何自定义序列化方法,已注册:mod: ' kombu.serialization.registry '。默认为:attr: ' serializer '属性。
            compression (str): Optional compression method
                to use.  Can be one of ``zlib``, ``bzip2``,
                or any custom compression methods registered with
                :func:`kombu.compression.register`.
                Defaults to the :setting:`task_compression` setting.
			可选压缩方法使用。可以是' ' zlib ' ', ' ' ' bzip2 ' ',或任何自定义的压缩方法注册:func: ' kombu.compression.register '。默认为:setting: ' task_compression '设置。
			不重要
            link (Signature): A single, or a list of tasks signatures
                to apply if the task returns successfully.
			任务成功返回时应用的单个或任务列表签名。
            link_error (Signature): A single, or a list of task signatures
                to apply if an error occurs while executing the task.
		在执行任务时发生错误时应用的单个或一组任务签名。
            producer (kombu.Producer): custom producer to use when publishing
                the task.
                发布任务时使用的自定义生成器。

            add_to_parent (bool): If set to True (default) and the task
                is applied while executing another task, then the result
                will be appended to the parent tasks ``request.children``
                attribute.  Trailing can also be disabled by default using the
                :attr:`trail` attribute
                如果设置为True(默认),并且在执行另一个任务时应用该任务,那么结果将被追加到父任务' ' request。孩子“属性。默认情况下也可以使用:attr: ' trail '属性禁用尾随

            publisher (kombu.Producer): Deprecated alias to ``producer``.
不赞成使用' ' producer ' '的别名。
            headers (Dict): Message headers to be included in the message.
将包含在消息中的消息标题。
        Returns:
            celery.result.AsyncResult: Promise of future evaluation.

        Raises:
            TypeError: If not enough arguments are passed, or too many
                arguments are passed.  Note that signature checks may
                be disabled by specifying ``@task(typing=False)``.
            kombu.exceptions.OperationalError: If a connection to the
               transport cannot be made, or if the connection is lost.

        Note:
            Also supports all keyword arguments supported by
            :meth:`kombu.Producer.publish`.
        """
 类似资料: