o
    wvXjö»  ã                   @   sŒ  d Z ddlmZmZ ddlZddlZddlZddlmZm	Z	 ddl
m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@mAZAmBZB ddlCmDZDmEZEmFZF ddlGmHZH ddlImJZJmKZK ddlLmMZMmNZNmOZO ddlPmQZQ ddlPmRZR dd lSmTZU dd!lVmWZWmXZX dd"lYmZZZ dd#l[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZd d$ZeeHefƒZgd%hZheji jd&¡Zkd'Zld(d)„ Zmd*d+„ Znd,d-„ ZoG d.d/„ d/e0e<ƒZpe2G d0d1„ d1eqƒƒZrerZsdS )2z#Actual App instance implementation.é    )Úabsolute_importÚunicode_literalsN)ÚdefaultdictÚdeque)Údatetime©Ú
attrgetter)Úpools)ÚLamportClock©Úoid_from)Úregister_after_fork)Úcached_property)Úuuid)Ústarpromise)Úwraps)Ú	platformsÚsignals)	Ú_announce_app_finalizedÚ_deregister_appÚ_register_appÚ_set_current_appÚ_task_stackÚconnect_on_app_finalizeÚget_current_appÚget_current_worker_taskÚset_default_app)ÚAlwaysEagerIgnoredÚImproperlyConfiguredÚIgnoreÚRetry)ÚUserDictÚbytes_if_py2Úpython_2_unicode_compatibleÚvalues)Úget_loader_cls)ÚPromiseProxyÚmaybe_evaluate)Úabstract)ÚAttributeDictMixin)ÚSignal)ÚfirstÚhead_from_funÚ
maybe_list)Úgen_task_nameÚinstantiateÚsymbol_by_name)Ú
get_logger)ÚFallbackContextÚ
mro_lookup)Ú get_exponential_backoff_intervalÚtimezoneÚto_utcé   )Úbuiltins)Úbackends)Úprepare)ÚDEFAULT_SECURITY_DIGESTÚfind_deprecated_settings)ÚTaskRegistry)	Ú
AppPicklerÚSettingsÚ_new_key_to_oldÚ_old_key_to_newÚ_unpickle_appÚ_unpickle_app_v2ÚappstrÚ	bugreportÚdetect_settings)ÚCeleryzcelery.fixups.django:fixupÚFORKED_BY_MULTIPROCESSINGzØ
The environment variable {0!r} is not set,
and as such the configuration could not be loaded.

Please set this variable and make sure it points to
a valid configuration module.

Example:
    {0}="proj.celeryconfig"
c                 C   s   t | j|tthtgd�S )zÿReturn true if app has customized method `attr`.

    Note:
        This is used for optimizations in cases where we know
        how the default behavior works, but need to account
        for someone using inheritance to override a method/property.
    )ÚstopÚmonkey_patched)r3   Ú	__class__rG   ÚobjectÚ__name__)ÚappÚattr© rP   úL/var/www/html/myproject/venv/lib/python3.10/site-packages/celery/app/base.pyÚapp_has_customH   s   ÿrR   c                 C   s   t ƒ  | ¡|Ž S )zUnpickle app.)r   Ú	_rgetattr)Úreverse_nameÚargsrP   rP   rQ   Ú_unpickle_appattrT   s   rV   c              
   C   sF   z|   ¡  W d S  ty" } ztjd|dd� W Y d }~d S d }~ww )Nz!after forker raised exception: %rr7   )Úexc_info)Ú_after_forkÚ	ExceptionÚloggerÚinfo)rN   ÚexcrP   rP   rQ   Ú_after_fork_cleanup_app[   s   €ÿr]   c                   @   s`   e Zd ZdZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zedd„ ƒZdS )ÚPendingConfigurationNc                 C   s    t  | d|¡ t  | d|¡ d S )NÚ_dataÚcallback)rL   Ú__setattr__)ÚselfÚconfr`   rP   rP   rQ   Ú__init__o   s   zPendingConfiguration.__init__c                 C   s   || j |< d S ©N©r_   ©rb   ÚkeyÚvaluerP   rP   rQ   Ú__setitem__s   ó   z PendingConfiguration.__setitem__c                 C   s   | j  ¡  d S re   )r_   Úclear©rb   rP   rP   rQ   rl   v   rk   zPendingConfiguration.clearc                 O   s   | j j|i |¤Ž d S re   )r_   Úupdate©rb   rU   ÚkwargsrP   rP   rQ   rn   y   ó   zPendingConfiguration.updatec                 O   s   | j j|i |¤ŽS re   )r_   Ú
setdefaultro   rP   rP   rQ   rr   |   ó   zPendingConfiguration.setdefaultc                 C   s
   || j v S re   rf   )rb   rh   rP   rP   rQ   Ú__contains__   s   
z!PendingConfiguration.__contains__c                 C   ó
   t | jƒS re   )ÚlenÚdatarm   rP   rP   rQ   Ú__len__…   ó   
zPendingConfiguration.__len__c                 C   ru   re   )Úreprrw   rm   rP   rP   rQ   Ú__repr__ˆ   ry   zPendingConfiguration.__repr__c                 C   ó   |   ¡ S re   )r`   rm   rP   rP   rQ   rw   ‹   ó   zPendingConfiguration.data)rM   Ú
__module__Ú__qualname__r`   r_   rd   rj   rl   rn   rr   rt   rx   r{   r   rw   rP   rP   rP   rQ   r^   d   s    r^   c                   @   sÚ  e Zd ZdZeZejZejej	ZZ	dZ
dZdZeZdZdZdZdZdZdZdZdZdZdZdZd	ZdZdZdZdZ					
d°dd„Zdd„ Z dd„ Z!dd„ Z"dd„ Z#dd„ Z$dd„ Z%dd„ Z&d±dd„Z'd±dd„Z(dd „ Z)d²d!d"„Z*d#d$„ Z+d%d&„ Z,d³d'd(„Z-d)d*„ Z.	d´d+d,„Z/dµd-d.„Z0d¶d0d1„Z1dddde2d2fd3d4„Z3			d·d6d7„Z4d8d9„ Z5d:d;„ Z6d<d=„ Z7								d¸d?d@„Z8d±dAdB„Z9d±dCdD„Z:					d¹dEdF„Z;					dºdGdH„Z<e;Z=d»dIdJ„Z>d¼dKdL„Z?e?Z@d±dMdN„ZAeAZBdOdP„ ZCdQdR„ ZDd±dSdT„ZEdUdV„ ZFdWdX„ ZGdYdZ„ ZHd[d\„ ZId]d^„ ZJd_d`„ ZKdadb„ ZL	d½ddde„ZM	d¾dfdg„ZNdhdi„ ZOdjdk„ ZP	l		d¿dmdn„ZQdodp„ ZRdqdr„ ZSdsdt„ ZTdudv„ ZUdwdx„ ZVdydz„ ZWd{d|„ ZXd}d~„ ZYeZdd€„ ƒZ[eZd�d‚„ ƒZ\eZdƒd„„ ƒZ]eZd…d†„ ƒZ^eZd‡dˆ„ ƒZ_eZd‰dŠ„ ƒZ`eZd‹dŒ„ ƒZaeZd�dŽ„ ƒZbecd�d�„ ƒZdecd‘d’„ ƒZeecd“d”„ ƒZfeZd•d–„ ƒZgeZd—d˜„ ƒZheZd™dš„ ƒZiecd›dœ„ ƒZjejjkd�dœ„ ƒZjeZdždŸ„ ƒZleZd d¡„ ƒZmeZd¢d£„ ƒZneZd¤d¥„ ƒZoeZd¦d§„ ƒZpeZd¨d©„ ƒZqecdªd«„ ƒZrd¬d­„ ZseZd®d¯„ ƒZtdS )ÀrG   a¨  Celery application.

    Arguments:
        main (str): Name of the main module if running as `__main__`.
            This is used as the prefix for auto-generated task names.

    Keyword Arguments:
        broker (str): URL of the default broker used.
        backend (Union[str, Type[celery.backends.base.Backend]]):
            The result store backend class, or the name of the backend
            class to use.

            Default is the value of the :setting:`result_backend` setting.
        autofinalize (bool): If set to False a :exc:`RuntimeError`
            will be raised if the task registry or tasks are used before
            the app is finalized.
        set_as_current (bool):  Make this the global current app.
        include (List[str]): List of modules every worker should import.

        amqp (Union[str, Type[AMQP]]): AMQP object or class name.
        events (Union[str, Type[celery.app.events.Events]]): Events object or
            class name.
        log (Union[str, Type[Logging]]): Log object or class name.
        control (Union[str, Type[celery.app.control.Control]]): Control object
            or class name.
        tasks (Union[str, Type[TaskRegistry]]): A task registry, or the name of
            a registry class.
        fixups (List[str]): List of fix-up plug-ins (e.g., see
            :mod:`celery.fixups.django`).
        config_source (Union[str, class]): Take configuration from a class,
            or object.  Attributes may include any settings described in
            the documentation.
        task_cls (Union[str, Type[celery.app.task.Task]]): base task class to
            use. See :ref:`this section <custom-task-cls-app-wide>` for usage.
    Nzcelery.app.amqp:AMQPzcelery.app.events:Eventszcelery.app.log:Loggingzcelery.app.control:Controlzcelery.app.task:Taskz celery.app.registry:TaskRegistryFTc                    sü  t ƒ ˆ _|ˆ _|pˆ jˆ _|pˆ jˆ _|pˆ  ¡ ˆ _|pˆ jˆ _|p$ˆ jˆ _|p*ˆ j	ˆ _	|ˆ _
tˆ jƒˆ _ttƒˆ _ttƒˆ _|ˆ _|ˆ _|ˆ _dˆ _|ˆ _tƒ ˆ _tƒ ˆ _dˆ _t ¡ ˆ _tƒ ˆ _|	ˆ _tˆ jt ƒstˆ  ˆ jpqi ¡ˆ _t!ˆ dƒˆ _"|p}i ˆ _#tƒ ˆ _$ˆ  %d|
¡ ˆ  %d|¡ ˆ  %d|¡ ˆ  %d| &d¡¡ ˆ  %d| &d¡¡ t't(ˆ j#ˆ j)ƒˆ jt*t+fd�ˆ _,|d u rÀtˆ j-ƒn|ˆ _.‡ fd	d
„ˆ j.D ƒˆ _/ˆ j
rÕˆ  0¡  ˆ j1d u ràt2dd�ˆ _1t2ddhd�ˆ _3t2dd�ˆ _4t2dd�ˆ _5ˆ  6¡  t7ˆ ƒ d S )NFÚ__reduce_args__Ú
broker_urlÚresult_backendÚincludeÚbroker_use_sslÚredis_backend_use_ssl)ÚprefixÚkeysc                    s   g | ]}t |ƒˆ ƒ‘qS rP   )r0   )Ú.0Úfixuprm   rP   rQ   Ú
<listcomp>   s    z#Celery.__init__.<locals>.<listcomp>zapp.on_configure)Únamezapp.on_after_configureÚsource)r‹   Úproviding_argszapp.on_after_finalizezapp.on_after_fork)8r
   ÚclockÚmainÚamqp_clsÚ
events_clsÚ_get_default_loaderÚ
loader_clsÚlog_clsÚcontrol_clsÚtask_clsÚset_as_currentr0   Úregistry_clsr   ÚsetÚuser_optionsÚstepsÚautofinalizeÚ	namespaceÚstrict_typingÚ
configuredÚ_config_sourcer   Ú_pending_defaultsÚ_pending_periodic_tasksÚ	finalizedÚ	threadingÚLockÚ_finalize_mutexÚ_pendingÚ_tasksÚ
isinstancer=   rR   Ú_using_v1_reduceÚ_preconfÚ_preconf_set_by_autoÚ_Celery__autosetÚgetr?   r^   Ú_finalize_pending_confrA   r@   Ú_confÚbuiltin_fixupsÚfixupsÚ_fixupsÚset_currentÚon_configurer*   Úon_after_configureÚon_after_finalizeÚon_after_forkÚon_initr   )rb   r�   ÚloaderÚbackendÚamqpÚeventsÚlogÚcontrolr—   ÚtasksÚbrokerrƒ   ÚchangesÚconfig_sourcer²   r–   rœ   r�   rž   rp   rP   rm   rQ   rd   æ   sl   



ÿü
þzCelery.__init__c                 C   s   t j d¡p
| jp
dS )NÚCELERY_LOADERzcelery.loaders.app:AppLoader)ÚosÚenvironr®   r“   rm   rP   rP   rQ   r’   3  s
   ÿýzCelery._get_default_loaderc                 C   s   dS )z!Optional callback called at init.NrP   rm   rP   rP   rQ   r¹   ;  ó    zCelery.on_initc                 C   s"   |r|| j |< | j |¡ d S d S re   )r«   r¬   Úaddrg   rP   rP   rQ   Ú	__autoset>  s   
þzCelery.__autosetc                 C   ó   t | ƒ dS )z*Make this the current app for this thread.N)r   rm   rP   rP   rQ   r´   C  ó   zCelery.set_currentc                 C   rÊ   )z*Make this the default app for all threads.N)r   rm   rP   rP   rQ   Úset_defaultG  rË   zCelery.set_defaultc                 C   s*   | j sd| _ td urt| tƒ d S d S d S ©NT)Ú_after_fork_registeredr   r]   rm   rP   rP   rQ   Ú_ensure_after_forkK  s   ýzCelery._ensure_after_forkc                 C   s   d| _ t| ƒ dS )aO  Clean up after the application.

        Only necessary for dynamically created apps, and you should
        probably use the :keyword:`with` statement instead.

        Example:
            >>> with Celery(set_as_current=False) as app:
            ...     with app.connection_for_write() as conn:
            ...         pass
        N)Ú_poolr   rm   rP   rP   rQ   ÚcloseQ  s   zCelery.closec                 C   ó   t d| d� |¡S )zgRun :program:`celery` using `argv`.

        Uses :data:`sys.argv` if `argv` is not specified.
        zcelery.bin.celery:CeleryCommand©rN   ©r/   Úexecute_from_commandline©rb   ÚargvrP   rP   rQ   Ústart_  ó
   ÿþzCelery.startc                 C   rÒ   )znRun :program:`celery worker` using `argv`.

        Uses :data:`sys.argv` if `argv` is not specified.
        zcelery.bin.worker:workerrÓ   rÔ   rÖ   rP   rP   rQ   Úworker_mainh  rÙ   zCelery.worker_mainc                    sž   t r| dd¡rddlm} ||ddi|¤ŽS d‡ fdd„	}t|ƒdkr7t|d	 ƒr3|di |¤Ž|Ž S td
ƒ‚|rHtd tt|ƒt|ƒgƒ¡ƒ‚|di |¤ŽS )a÷  Decorator to create a task class out of any callable.

        See :ref:`Task options<task-options>` for a list of the
        arguments that can be passed to this decorator.

        Examples:
            .. code-block:: python

                @app.task
                def refresh_feed(url):
                    store_feed(feedparser.parse(url))

            with setting extra options:

            .. code-block:: python

                @app.task(exchange='feeds')
                def refresh_feed(url):
                    return store_feed(feedparser.parse(url))

        Note:
            App Binding: For custom apps the task decorator will return
            a proxy object, so that the act of creating the task is not
            performed until the task is used or the task registry is accessed.

            If you're depending on binding to be deferred, then you must
            not access any attributes on the returned object until the
            application is fully set up (finalized).
        ÚlazyTr7   )Úshared_taskFNc                    s   |‰ ‡ ‡‡‡‡fdd„}|S )Nc                    sr   ˆr‡ ‡fdd„}ˆ j |_ t|ƒ ˆrˆjr ˆjˆ fi ˆ¤Ž}ntˆjˆ fˆˆ jd�}ˆj |¡ ˆr7ˆ|ƒS |S )Nc                    s   | j ˆ fi ˆ¤ŽS re   )Ú_task_from_funrÓ   )ÚfunÚoptsrP   rQ   Úcons�  rs   zRCelery.task.<locals>.inner_create_task_cls.<locals>._create_task_cls.<locals>.cons)Ú__doc__)rM   r   r£   rÝ   r&   rá   r§   Úappend)rÞ   rà   Úret)Ú_filtrÛ   rß   rb   Úshared)rÞ   rQ   Ú_create_task_cls›  s   
ÿzDCelery.task.<locals>.inner_create_task_cls.<locals>._create_task_clsrP   )rå   ÚfilterrÛ   rß   ræ   rm   )rä   rÛ   rß   rå   rQ   Úinner_create_task_cls˜  s   z*Celery.task.<locals>.inner_create_task_clsr   z(argument 1 to @task() must be a callablez,@task() takes exactly 1 argument ({0} given))TNTrP   )	ÚUSING_EXECVr®   Ú rÜ   rv   ÚcallableÚ	TypeErrorÚformatÚsum)rb   rU   rß   rÜ   rè   rP   rm   rQ   Útaskq  s   ÿÿzCelery.taskc                    s‚  | j s
| js
tdƒ‚|p|  |j|j¡}|p| j}|| jvrº|r"|nt|ƒ}t	|j|ft
| ||d|j|jtt||d�ƒ|dœfi |¤Žƒƒ ‰z|jˆ_W n	 tyU   Y nw ˆ| jˆj< ˆ | ¡ t| dtˆddƒ¡ƒ‰ | dtˆdi ƒ¡‰t| dtˆdd	ƒ¡ƒ‰t| d
tˆd
dƒ¡ƒ‰| dtˆddƒ¡‰ˆ r¸tˆdƒs¸tˆjƒ‡ ‡‡‡‡‡fdd„ƒ}ˆj|ˆ_ˆ_ˆS | j| ‰ˆS )Nú"Contract breach: app not finalizedT)Úbound)rN   r‹   ÚrunÚ
_decoratedrá   r~   Ú
__header__Ú__wrapped__Úautoretry_forrP   Úretry_kwargsÚretry_backoffFÚretry_backoff_maxiX  Úretry_jitterÚ	_orig_runc               
      sx   z	ˆj | i |¤ŽW S  ty   ‚  ty   ‚  ˆ y; } zˆr-tˆˆjjˆˆd�ˆd< ˆjdd|iˆ¤Ž‚d }~ww )N)ÚfactorÚretriesÚmaximumÚfull_jitterÚ	countdownr\   rP   )rû   r   r    r4   Úrequestrý   Úretry)rU   rp   r\   ©rö   rø   rù   rú   r÷   rï   rP   rQ   rò   ç  s$   üÿ€øz"Celery._task_from_fun.<locals>.run)r£   rœ   ÚRuntimeErrorr.   rM   r~   ÚTaskr¨   ÚstaticmethodÚtypeÚdictrá   r,   r   ÚAttributeErrorr‹   ÚbindÚtupler®   ÚgetattrÚintÚhasattrr   rò   rû   )rb   rÞ   r‹   Úbaser
  Úoptionsrò   rP   r  rQ   rÝ   ¸  sj   

ø
øÿ

ÿÿÿ
ÿÿ
ÿÿÿ
ÿzCelery._task_from_func                 C   s@   |j st|ƒ}|  |j|j¡|_ || j|j < | |_| | ¡ |S )zàUtility for registering a task-based class.

        Note:
            This is here for compatibility with old Celery 1.0
            style task classes, you should not need to use this for
            new projects.
        )r‹   r  r.   rM   r~   rÀ   Ú_appr
  )rb   rï   r–   rP   rP   rQ   Úregister_task   s   ÿ
zCelery.register_taskc                 C   s   t | ||ƒS re   )r.   )rb   r‹   ÚmodulerP   rP   rQ   r.     ó   zCelery.gen_task_namec                 C   s¤   | j �E | js@|r| jstdƒ‚d| _t| ƒ | j}|r$t| ¡ ƒ |st| j	ƒD ]}| 
| ¡ q)| jj| d� W d  ƒ dS W d  ƒ dS 1 sKw   Y  dS )zƒFinalize the app.

        This loads built-in tasks, evaluates pending task decorators,
        reads configuration, etc.
        rð   T©ÚsenderN)r¦   r£   rœ   r  r   r§   r'   Úpopleftr$   r¨   r
  r·   Úsend)rb   ÚautoÚpendingrï   rP   rP   rQ   Úfinalize  s    
ÿò"ÿzCelery.finalizec                    s>   t |ƒs|‡ fdd„‰ }| jr| j |ƒ ¡S | j |¡ dS )ad  Add default configuration from dict ``d``.

        If the argument is a callable function then it will be regarded
        as a promise, and it won't be loaded until the configuration is
        actually needed.

        This method can be compared to:

        .. code-block:: pycon

            >>> celery.conf.update(d)

        with a difference that 1) no copy will be made and 2) the dict will
        not be transferred when the worker spawns child processes, so
        it's important that the same configuration happens at import time
        when pickle restores the object on the other side.
        c                      s   ˆ S re   rP   rP   ©ÚdrP   rQ   Ú<lambda>=  rÇ   z%Celery.add_defaults.<locals>.<lambda>N)rë   rŸ   r°   Úadd_defaultsr¡   râ   )rb   rÞ   rP   r  rQ   r  *  s
   zCelery.add_defaultsc                 C   s@   || _ |p| j| _|s| jrd| _| jj||d�r| jS dS dS )a  Read configuration from object.

        Object is either an actual object or the name of a module to import.

        Example:
            >>> celery.config_from_object('myapp.celeryconfig')

            >>> from myapp import celeryconfig
            >>> celery.config_from_object(celeryconfig)

        Arguments:
            silent (bool): If true then import errors will be ignored.
            force (bool): Force reading configuration immediately.
                By default the configuration will be read only when required.
        N)Úsilent)r    r�   rŸ   r°   rº   Úconfig_from_objectrc   )rb   Úobjr   Úforcer�   rP   rP   rQ   r!  B  s   
ÿþzCelery.config_from_objectc                 C   s:   t j |¡}|s|rdS tt ¡  |¡ƒ‚| j|||d�S )a3  Read configuration from environment variable.

        The value of the environment variable must be the name
        of a module to import.

        Example:
            >>> os.environ['CELERY_CONFIG_MODULE'] = 'myapp.celeryconfig'
            >>> celery.config_from_envvar('CELERY_CONFIG_MODULE')
        F)r   r#  )rÅ   rÆ   r®   r   ÚERR_ENVVAR_NOT_SETÚstriprí   r!  )rb   Úvariable_namer   r#  Úmodule_namerP   rP   rQ   Úconfig_from_envvarZ  s   
ÿzCelery.config_from_envvarÚceleryc                 C   s   | j  | j ||¡¡ d S re   )r°   rn   rº   Úcmdline_config_parser)rb   r×   r�   rP   rP   rQ   Úconfig_from_cmdlinel  s   ÿzCelery.config_from_cmdlineÚjsonc              	   C   s"   ddl m} |||||||| d�S )aª  Setup the message-signing serializer.

        This will affect all application instances (a global operation).

        Disables untrusted serializers and if configured to use the ``auth``
        serializer will register the ``auth`` serializer with the provided
        settings into the Kombu serializer registry.

        Arguments:
            allowed_serializers (Set[str]): List of serializer names, or
                content_types that should be exempt from being disabled.
            key (str): Name of private key file to use.
                Defaults to the :setting:`security_key` setting.
            cert (str): Name of certificate file to use.
                Defaults to the :setting:`security_certificate` setting.
            store (str): Directory containing certificates.
                Defaults to the :setting:`security_cert_store` setting.
            digest (str): Digest algorithm used when signing messages.
                Default is ``sha256``.
            serializer (str): Serializer used to encode messages after
                they've been signed.  See :setting:`task_serializer` for
                the serializers supported.  Default is ``json``.
        r   )Úsetup_securityrÓ   )Úcelery.securityr-  )rb   Úallowed_serializersrh   ÚcertÚstoreÚdigestÚ
serializerr-  rP   rP   rQ   r-  q  s   ÿzCelery.setup_securityrÀ   c                 C   s0   |r|   ||¡S tjjt| j ||ƒd| d� dS )aœ  Auto-discover task modules.

        Searches a list of packages for a "tasks.py" module (or use
        related_name argument).

        If the name is empty, this will be delegated to fix-ups (e.g., Django).

        For example if you have a directory layout like this:

        .. code-block:: text

            foo/__init__.py
               tasks.py
               models.py

            bar/__init__.py
                tasks.py
                models.py

            baz/__init__.py
                models.py

        Then calling ``app.autodiscover_tasks(['foo', 'bar', 'baz'])`` will
        result in the modules ``foo.tasks`` and ``bar.tasks`` being imported.

        Arguments:
            packages (List[str]): List of packages to search.
                This argument may also be a callable, in which case the
                value returned is used (for lazy evaluation).
            related_name (str): The name of the module to find.  Defaults
                to "tasks": meaning "look for 'module.tasks' for every
                module in ``packages``.".  If ``None`` will only try to import
                the package, i.e. "look for 'module'".
            force (bool): By default this call is lazy so that the actual
                auto-discovery won't happen until an application imports
                the default modules.  Forcing will cause the auto-discovery
                to happen immediately.
        F)Úweakr  N)Ú_autodiscover_tasksr   Úimport_modulesÚconnectr   )rb   ÚpackagesÚrelated_namer#  rP   rP   rQ   Úautodiscover_tasks�  s   (ÿ
þzCelery.autodiscover_tasksc                 K   s   |r|   ||¡S |  |¡S re   )Ú_autodiscover_tasks_from_namesÚ_autodiscover_tasks_from_fixups)rb   r8  r9  rp   rP   rP   rQ   r5  ½  s   
zCelery._autodiscover_tasksc                 C   s    | j  t|ƒr|ƒ |¡S ||¡S re   )rº   r:  rë   )rb   r8  r9  rP   rP   rQ   r;  Â  s
   ÿÿz%Celery._autodiscover_tasks_from_namesc                 C   s   | j dd„ | jD ƒ|d�S )Nc                 S   s(   g | ]}|  ¡ D ]	}t|d ƒr|‘qqS )r:  )r:  r  )rˆ   r‰   ÚpkgrP   rP   rQ   rŠ   É  s    þýÿz:Celery._autodiscover_tasks_from_fixups.<locals>.<listcomp>)r9  )r;  r³   )rb   r9  rP   rP   rQ   r<  È  s
   
ÿüz&Celery._autodiscover_tasks_from_fixupsr   c           %      K   sÔ  d }}| j }|ptƒ }|p|}|	p|j}	| j} | jr$tjtdƒdd� | dd¡}!|	 	||p0||||¡}|r9|s\| j
}|r\|sH|jjpG|jj}|sN|jj}| jr\| d|jj d¡¡ |j||||||||||t|ƒt|ƒ|pr| j||| jj||||| d¡| d	¡d
�}"|r�|j|dd�}|  |¡�1}#|#j ¡ � |!s¤| j |#|¡ |j|#||"fi |¤Ž W d  ƒ n1 s¹w   Y  W d  ƒ n1 sÈw   Y  |
pÑ| j|ƒ}$|!|$_|rè|sá| j
d}}|rè| |$¡ |$S )zúSend task by name.

        Supports the same arguments as :meth:`@-Task.apply_async`.

        Arguments:
            name (str): Name of task to call (e.g., `"tasks.add"`).
            result_cls (AsyncResult): Specify custom result class.
        Nz,task_always_eager has no effect on send_taské   )Ú
stacklevelÚignore_resultFÚpriorityÚargsreprÚ
kwargsrepr)rB  rC  )Úauto_declareT) r¼   r   Úrouterrc   Útask_always_eagerÚwarningsÚwarnr   ÚpopÚrouteÚcurrent_worker_taskr  Úroot_idÚidÚtask_inherit_parent_priorityrr   Údelivery_infor®   Úcreate_task_messager-   ÚoidÚtask_send_sent_eventÚProducerÚproducer_or_acquireÚ
connectionÚ_reraise_as_library_errorsr»   Úon_task_callÚsend_task_messageÚAsyncResultÚignoredÚ	add_trail)%rb   r‹   rU   rp   r   ÚetaÚtask_idÚproducerrU  rE  Ú
result_clsÚexpiresÚ	publisherÚlinkÚ
link_errorÚadd_to_parentÚgroup_idrý   ÚchordÚreply_toÚ
time_limitÚsoft_time_limitrL  Ú	parent_idÚ
route_nameÚshadowÚchainÚ	task_typer  ÚparentÚhave_parentr¼   rc   Úignored_resultÚmessageÚPÚresultrP   rP   rQ   Ú	send_taskÏ  sn   

ÿþÿÿøý€ÿ
zCelery.send_taskc                 K   ó   | j |p| jjfi |¤ŽS )z|Establish connection used for consuming.

        See Also:
            :meth:`connection` for supported arguments.
        )Ú_connectionrc   Úbroker_read_url©rb   Úurlrp   rP   rP   rQ   Úconnection_for_read  ó   zCelery.connection_for_readc                 K   rv  )z|Establish connection used for producing.

        See Also:
            :meth:`connection` for supported arguments.
        )rw  rc   Úbroker_write_urlry  rP   rP   rQ   Úconnection_for_write"  r|  zCelery.connection_for_writec                 K   s2   | j |p| jjf||||||||	|
||dœ|¤ŽS )aC  Establish a connection to the message broker.

        Please use :meth:`connection_for_read` and
        :meth:`connection_for_write` instead, to convey the intent
        of use for this connection.

        Arguments:
            url: Either the URL or the hostname of the broker to use.
            hostname (str): URL, Hostname/IP-address of the broker.
                If a URL is used, then the other argument below will
                be taken from the URL instead.
            userid (str): Username to authenticate as.
            password (str): Password to authenticate with
            virtual_host (str): Virtual host to use (domain).
            port (int): Port to connect to.
            ssl (bool, Dict): Defaults to the :setting:`broker_use_ssl`
                setting.
            transport (str): defaults to the :setting:`broker_transport`
                setting.
            transport_options (Dict): Dictionary of transport specific options.
            heartbeat (int): AMQP Heartbeat in seconds (``pyamqp`` only).
            login_method (str): Custom login method to use (AMQP only).
            failover_strategy (str, Callable): Custom failover strategy.
            **kwargs: Additional arguments to :class:`kombu.Connection`.

        Returns:
            kombu.Connection: the lazy connection instance.
        )ÚuseridÚpasswordÚvirtual_hostÚportÚsslÚconnect_timeoutÚ	transportÚtransport_optionsÚ	heartbeatÚlogin_methodÚfailover_strategy)r~  rc   r}  )rb   Úhostnamer  r€  r�  r‚  rƒ  r„  r…  r†  r‡  rˆ  r‰  rp   rP   rP   rQ   rU  *  s   !
ÿúùzCelery.connectionc                 K   sv   | j }| jj||p|j|p|j|p|j|p|j|p|j|  d|¡|
|p%|j	|p)|j
t|jfi |	p1i ¤Ž|  d|¡d�S )Nr„   Úbroker_connection_timeout)r…  rƒ  r‡  rˆ  r‰  r†  r„  )rc   r¼   Ú
ConnectionÚbroker_userÚbroker_passwordÚbroker_vhostÚbroker_portÚbroker_transportÚeitherÚbroker_login_methodÚbroker_failover_strategyr  Úbroker_transport_options)rb   rz  r  r€  r�  r‚  rƒ  r„  r…  r†  r‡  rˆ  r‰  rp   rc   rP   rP   rQ   rw  U  s*   
ÿÿÿðzCelery._connectionc                 C   s   |r	| j jdd�S |  ¡ S )z)Helper for :meth:`connection_or_acquire`.T©Úblock)ÚpoolÚacquirer~  )rb   r˜  rP   rP   rQ   Ú_acquire_connectionq  s   zCelery._acquire_connectionc                 O   s   t || j|d�S )aR  Context used to acquire a connection from the pool.

        For use within a :keyword:`with` statement to get a connection
        from the pool if one is not already provided.

        Arguments:
            connection (kombu.Connection): If not provided, a connection
                will be acquired from the connection pool.
        )r˜  )r2   rš  )rb   rU  r˜  Ú_Ú__rP   rP   rQ   Úconnection_or_acquirew  s   
zCelery.connection_or_acquirec                 C   s   t || jjdd�S )aE  Context used to acquire a producer from the pool.

        For use within a :keyword:`with` statement to get a producer
        from the pool if one is not already provided

        Arguments:
            producer (kombu.Producer): If not provided, a producer
                will be acquired from the producer pool.
        Tr–  )r2   Úproducer_poolr™  )rb   r^  rP   rP   rQ   rT  „  s   

ÿzCelery.producer_or_acquirec                 C   s   t |ƒS )z<Prepare configuration before it is merged with the defaults.)r<   )rb   ÚcrP   rP   rQ   Úprepare_config“  r}   zCelery.prepare_configc                 C   s   t t ¡ ƒ}| | j¡S )z/Return the current time and date as a datetime.)r6   r   ÚutcnowÚ
astimezoner5   )rb   Ú
now_in_utcrP   rP   rQ   Únow—  s   z
Celery.nowc                 C   s   | j j |¡S )zxSelect subset of queues.

        Arguments:
            queues (Sequence[str]): a list of queue names to keep.
        )r¼   ÚqueuesÚselect)rb   r¥  rP   rP   rQ   Úselect_queuesœ  s   zCelery.select_queuesc                 G   s   t dt d|ƒt| jj|ƒgƒS )z›Get key from configuration or use default values.

        Fallback to the value of a configuration key if none of the
        `*values` are true.
        N)r+   r   rc   r®   )rb   Údefault_keyÚdefaultsrP   rP   rQ   r’  ¤  s   ÿzCelery.eitherc                 C   s   t | ƒS )z)Return information useful in bug reports.)rE   rm   rP   rP   rQ   rE   ®  r}   zCelery.bugreportc                 C   s(   t  | jp| jj| j¡\}}|| |d�S )N)rN   rz  )r9   Úby_urlÚbackend_clsrc   r‚   rº   )rb   r»   rz  rP   rP   rQ   Ú_get_backend²  s
   þzCelery._get_backendc                 C   s   |   ¡  }| _|S )zÐGet config value by key and finalize loading the configuration.

        Note:
            This is used by PendingConfiguration:
                as soon as you access a key the configuration is read.
        )Ú_load_configr°   ©rb   rc   rP   rP   rQ   r¯   ¸  s   zCelery._finalize_pending_confc                 C   sÔ   t | jtƒr| jj| d� n|  ¡  | jr| j | j¡ d| _t|  	| jj
¡| j| j| jd�}| jd ur;| j |¡ n|| _| j}|rP| j t| ¡ ƒ ƒ¡ |sC| j}|r^| j| ¡ Ž  |sU| jj| | jd� | jS )Nr  T)Úignore_keysr†   )r  rŒ   )r©   rµ   r*   r  r    rº   r!  rŸ   rF   r   rc   r«   r¬   r�   r°   Ú	swap_withr¡   r  r'   r  r¢   Ú_add_periodic_taskr¶   )rb   ÚsettingsÚpending_defÚpending_beatrP   rP   rQ   r­  Â  s.   þ
ÿÿzCelery._load_configc              	   C   s@   d | _ zd | jd _W n ttfy   Y nw | jj| d� d S )Nr¼   r  )rÐ   Ú__dict__Ú_producer_poolr	  ÚKeyErrorr¸   r  rm   rP   rP   rQ   rX   ä  s   ÿzCelery._after_forkc                 O   s   | |d< | j j|i |¤ŽS )z:Return a new :class:`~celery.Signature` bound to this app.rN   )Ú_canvasÚ	signaturero   rP   rP   rQ   r¹  ì  s   zCelery.signaturerP   c           	      K   sH   | j |||||fi |¤Ž\}}| jr|  ||¡ |S | j ||f¡ |S re   )Ú_sig_to_periodic_task_entryrŸ   r±  r¢   râ   )	rb   ÚscheduleÚsigrU   rp   r‹   rß   rh   ÚentryrP   rP   rQ   Úadd_periodic_taskñ  s   
ÿ
ÿÿzCelery.add_periodic_taskc              	   K   sd   |si n|}t |tjƒr| ||¡n|  |j||¡}|pt|ƒ||j|j|jt	|j
fi |¤ŽdœfS )N)r»  rï   rU   rp   r  )r©   r(   ÚCallableSignatureÚcloner¹  r‹   rz   rU   rp   r  r  )rb   r»  r¼  rU   rp   r‹   rß   rP   rP   rQ   rº  û  s   
ÿþ
ûz"Celery._sig_to_periodic_task_entryc                 C   s   || j j|< d S re   )r°   Úbeat_schedule)rb   rh   r½  rP   rP   rQ   r±  	  ó   zCelery._add_periodic_taskc                 C   s   | j | jddddd�S )z+Create a base task class bound to this app.r  r  T)r‹   Ú	attributeÚkeep_reducer(   )Úsubclass_with_selfr–   rm   rP   rP   rQ   Úcreate_task_cls  s   þzCelery.create_task_clsrN   c           	         sd   t |ƒ}ˆ rˆ n|j‰ ‡ fdd„}t|| if|j|jdœ|¤Ž}|s&||d< tt|p,|jƒ|f|ƒS )aî  Subclass an app-compatible class.

        App-compatible means that the class has a class attribute that
        provides the default app it should use, for example:
        ``class Foo: app = None``.

        Arguments:
            Class (type): The app-compatible class to subclass.
            name (str): Custom name for the target class.
            attribute (str): Name of the attribute holding the app,
                Default is 'app'.
            reverse (str): Reverse path to this object used for pickling
                purposes. For example, to get ``app.AsyncResult``,
                use ``"AsyncResult"``.
            keep_reduce (bool): If enabled a custom ``__reduce__``
                implementation won't be provided.
        c                    s   t ˆ |  ¡ ffS re   )rV   r€   rm   ©ÚreverserP   rQ   Ú
__reduce__)  rÂ  z-Celery.subclass_with_self.<locals>.__reduce__)r~   rá   rÉ  )r0   rM   r  r~   rá   r  r"   )	rb   ÚClassr‹   rÃ  rÈ  rÄ  ÚkwrÉ  ÚattrsrP   rÇ  rQ   rÅ    s   ÿýüzCelery.subclass_with_selfc                 C   s   t |ƒ| ƒS re   r   )rb   ÚpathrP   rP   rQ   rS   6  r  zCelery._rgetattrc                 C   s   | S re   rP   rm   rP   rP   rQ   Ú	__enter__9  s   zCelery.__enter__c                 G   s   |   ¡  d S re   )rÑ   )rb   rW   rP   rP   rQ   Ú__exit__<  r  zCelery.__exit__c                 C   s   d  t| ƒjt| ƒ¡S )Nz	<{0} {1}>)rí   r  rM   rD   rm   rP   rP   rQ   r{   ?  rq   zCelery.__repr__c                 C   s    | j r|  ¡ S t| j|  ¡ ffS re   )rª   Ú__reduce_v1__rC   rK   Ú__reduce_keys__rm   rP   rP   rQ   rÉ  B  s   zCelery.__reduce__c                 C   s   t | j| jf|  ¡  fS re   )rB   rK   ÚPicklerr€   rm   rP   rP   rQ   rÐ  G  s   þzCelery.__reduce_v1__c                 C   sD   | j | jr	| jjn| j| j| j| j| j| j	| j
| j| j| j| jdœS )zAKeyword arguments used to reconstruct the object when unpickling.)r�   rÂ   rº   r»   r¼   r½   r¾   r¿   r²   rÃ   r–   r�   )r�   rŸ   r°   rÂ   r«   r“   r«  r�   r‘   r”   r•   r²   r    r–   r�   rm   rP   rP   rQ   rÑ  P  s   ózCelery.__reduce_keys__c              
   C   s6   | j | jr	| jjni | j| j| j| j| j| j	d| j
f
S )z>Deprecated method, please use :meth:`__reduce_keys__` instead.F)r�   rŸ   r°   rÂ   r“   r«  r�   r‘   r”   r•   r    rm   rP   rP   rQ   r€   b  s
   ýzCelery.__reduce_args__c                 C   ó
   |   d¡S )zNWorker application.

        See Also:
            :class:`~@Worker`.
        zcelery.apps.worker:Worker©rÅ  rm   rP   rP   rQ   ÚWorkeri  ó   
zCelery.Workerc                 K   rÓ  )zUEmbeddable worker.

        See Also:
            :class:`~@WorkController`.
        zcelery.worker:WorkControllerrÔ  ©rb   rp   rP   rP   rQ   ÚWorkControllerr  rÖ  zCelery.WorkControllerc                 K   rÓ  )zf:program:`celery beat` scheduler application.

        See Also:
            :class:`~@Beat`.
        zcelery.apps.beat:BeatrÔ  r×  rP   rP   rQ   ÚBeat{  rÖ  zCelery.Beatc                 C   r|   )zBase task class for this app.)rÆ  rm   rP   rP   rQ   r  „  ó   zCelery.Taskc                 C   s   t | jjƒS re   )Úprepare_annotationsrc   Útask_annotationsrm   rP   rP   rQ   Úannotations‰  rË   zCelery.annotationsc                 C   rÓ  )zgCreate new result instance.

        See Also:
            :class:`celery.result.AsyncResult`.
        zcelery.result:AsyncResultrÔ  rm   rP   rP   rQ   rY  �  rÖ  zCelery.AsyncResultc                 C   rÓ  )Nzcelery.result:ResultSetrÔ  rm   rP   rP   rQ   Ú	ResultSet–  ó   
zCelery.ResultSetc                 C   rÓ  )zmCreate new group result instance.

        See Also:
            :class:`celery.result.GroupResult`.
        zcelery.result:GroupResultrÔ  rm   rP   rP   rQ   ÚGroupResultš  rÖ  zCelery.GroupResultc                 C   s:   | j du r|  ¡  | jj}t |¡ tj|  ¡  | _ | j S )z‹Broker connection pool: :class:`~@pool`.

        Note:
            This attribute is not related to the workers concurrency pool.
        N)rÐ   rÏ   rc   Úbroker_pool_limitr	   Ú	set_limitÚconnectionsr~  )rb   ÚlimitrP   rP   rQ   r˜  £  s   

zCelery.poolc                 C   s   t jS )z2Instance of task being executed, or :const:`None`.)r   Útoprm   rP   rP   rQ   Úcurrent_task±  s   zCelery.current_taskc                 C   s   t ƒ S )zÈThe task currently being executed by a worker or :const:`None`.

        Differs from :data:`current_task` in that it's not affected
        by tasks calling other tasks directly, or eagerly.
        )r   rm   rP   rP   rQ   rK  ¶  s   zCelery.current_worker_taskc                 C   s   t | dd�S )z+Universally unique identifier for this app.F)Úthreadsr   rm   rP   rP   rQ   rQ  ¿  s   z
Celery.oidc                 C   ó   t | j| d�S )z,AMQP related functionality: :class:`~@amqp`.rÓ   )r/   r�   rm   rP   rP   rQ   r¼   È  ó   zCelery.amqpc                 C   r|   )zCurrent backend instance.)r¬  rm   rP   rP   rQ   r»   Í  rÚ  zCelery.backendc                 C   s   | j du r
|  ¡ | _ | j S )zCurrent configuration.N)r°   r­  rm   rP   rP   rQ   rc   Ò  s   

zCelery.confc                 C   s
   || _ d S re   )r°   )rb   r  rP   rP   rQ   rc   Ù  rß  c                 C   rè  )z#Remote control: :class:`~@control`.rÓ   )r/   r•   rm   rP   rP   rQ   r¿   Ý  ré  zCelery.controlc                 C   rè  )z0Consuming and sending events: :class:`~@events`.rÓ   )r/   r‘   rm   rP   rP   rQ   r½   â  ré  zCelery.eventsc                 C   s   t | jƒ| d�S )zCurrent loader instance.rÓ   )r%   r“   rm   rP   rP   rQ   rº   ç  s   zCelery.loaderc                 C   rè  )zLogging: :class:`~@log`.rÓ   )r/   r”   rm   rP   rP   rQ   r¾   ì  ré  z
Celery.logc                 C   s   ddl m} |S )Nr   )Úcanvas)r)  rê  )rb   rê  rP   rP   rQ   r¸  ñ  s   zCelery._canvasc                 C   s   | j dd� | jS )zoTask registry.

        Warning:
            Accessing this attribute will also auto-finalize the app.
        T)r  )r  r¨   rm   rP   rP   rQ   rÀ   ö  s   zCelery.tasksc                 C   s   | j jS re   )r¼   rž  rm   rP   rP   rQ   rž     r}   zCelery.producer_poolc                 C   s   | j t jkS )z/Check if the application uses the UTC timezone.)r5   Úutcrm   rP   rP   rQ   Úuses_utc_timezone  rË   zCelery.uses_utc_timezonec                 C   s*   | j }|js|jrtjS tjS t |j¡S )z�Current timezone for this app.

        This is a cached property taking the time zone from the
        :setting:`timezone` setting.
        )rc   r5   Ú
enable_utcrë  ÚlocalÚget_timezoner®  rP   rP   rQ   r5     s   zCelery.timezone)NNNNNNNTNNNNNNNTNTre   )NNF)F)FFN)FF)r)  )NrÀ   F)NNNNNNNNNNNNNTNr   NNNNNNNNNN)NNNNNNNNNNNN)NNNNNNNNNNN)TrÍ   )rP   rP   N)rP   NN)NrN   NF)urM   r~   r   rá   r>   rÒ  r   ÚSYSTEMÚIS_macOSÚ
IS_WINDOWSr�   rš   r›   ÚBUILTIN_FIXUPSr±   r�   r«  r‘   r“   r”   r•   r–   r˜   r³   rÐ   r°   rÎ   rµ   r¶   r·   r¸   rd   r’   r¹   r­   r´   rÌ   rÏ   rÑ   rØ   rÚ   rï   rÝ   r  r.   r  r  r!  r(  r+  r;   r-  r:  r5  r;  r<  ru  r{  r~  rU  rw  Úbroker_connectionrš  r�  Údefault_connectionrT  Údefault_producerr   r¤  r§  r’  rE   r¬  r¯   r­  rX   r¹  r¾  rº  r±  rÆ  rÅ  rS   rÎ  rÏ  r{   rÉ  rÐ  rÑ  r€   r   rÕ  rØ  rÙ  r  rÝ  rY  rÞ  rà  Úpropertyr˜  ræ  rK  rQ  r¼   r»   rc   Úsetterr¿   r½   rº   r¾   r¸  rÀ   rž  rì  r5   rP   rP   rP   rQ   rG   �   sJ   %
üM

		
GH

ÿ


þ
ÿ.
ù
K

ü+
ü





"
ÿ
ÿ
ÿ#	





















	
rG   )trá   Ú
__future__r   r   rÅ   r¤   rG  Úcollectionsr   r   r   Úoperatorr   Úkombur	   Úkombu.clocksr
   Úkombu.commonr   Úkombu.utils.compatr   Úkombu.utils.objectsr   Úkombu.utils.uuidr   Úviner   Ú
vine.utilsr   r)  r   r   Úcelery._stater   r   r   r   r   r   r   r   r   Úcelery.exceptionsr   r   r   r    Úcelery.fiver!   r"   r#   r$   Úcelery.loadersr%   Úcelery.localr&   r'   Úcelery.utilsr(   Úcelery.utils.collectionsr)   Úcelery.utils.dispatchr*   Úcelery.utils.functionalr+   r,   r-   Úcelery.utils.importsr.   r/   r0   Úcelery.utils.logr1   Úcelery.utils.objectsr2   r3   Úcelery.utils.timer4   r5   r6   rê   r8   r9   rÝ  r:   rÛ  r©  r;   r<   Úregistryr=   Úutilsr>   r?   r@   rA   rB   rC   rD   rE   rF   Ú__all__rM   rZ   ró  rÆ   r®   ré   r$  rR   rV   r]   r^   rL   rG   ÚApprP   rP   rP   rQ   Ú<module>   st   ,,ÿ	,         