HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/utils/__pycache__/threads.cpython-39.pyc
a

X>hP%�@srdZddlZddlZddlZddlZddlZddlmZddlmZ	ddl
mZzddlm
ZWn�ey�zddlmZWnfey�zddlmZWnBey�zddlmZWney�ddlmZYn0Yn0Yn0Yn0dZej�d	�Zed
d��ZGdd
�d
ej�Zdd�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�dej�Z e�rje Z!neZ!dS)z#Threading primitives and utilities.�N)�contextmanager)�TIMEOUT_MAX��Proxy)�
getcurrent)�	get_ident)�bgThread�Local�
LocalStack�LocalManagerr�default_socket_timeout�USE_FAST_LOCALSccs&t��}t�|�dVt�|�dS)z7Context temporarily setting the default socket timeout.N)�socket�getdefaulttimeout�setdefaulttimeout)�timeout�prev�r�>/usr/local/lib/python3.9/site-packages/celery/utils/threads.pyr#s
rcsJeZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)rzBackground service thread.Ncs6t���t��|_t��|_d|_|p.|jj|_	dS)NT)
�super�__init__�	threading�Event�_bgThread__is_shutdown�_bgThread__is_stopped�daemon�	__class__�__name__�name)�selfr�kwargs�rrrr/s



zbgThread.__init__cCs
t��dS�N)�NotImplementedError�rrrr�body6sz
bgThread.bodycOs&t|j|�tjd�t�dtj�dS)N)�file)�print�format�sys�stderr�	traceback�	print_exc)r�msg�fmtr rrr�on_crash9szbgThread.on_crashcCs�|j}|jj}z�|�s�z
|�Wqty�}zTz0|�d|j|�|��Wtj�	�t
�d�ntj�	�t
�d�0WYd}~qd}~00qW|��n
|��0dS)Nz{0!r} crashed: {1!r}�)r%r�is_set�	Exceptionr/r�_set_stoppedr)r*�flush�os�_exit)rr%Zshutdown_set�excrrr�run=s


�
&zbgThread.runcCs&z|j��Wnty Yn0dSr")r�set�	TypeErrorr$rrrr3NszbgThread._set_stoppedcCs*|j��|j��|��r&|�t�dS)zGraceful shutdown.N)rr9r�wait�is_alive�join�THREAD_TIMEOUT_MAXr$rrr�stopVs

z
bgThread.stop)N)r�
__module__�__qualname__�__doc__rr%r/r8r3r?�
__classcell__rrr!rr,srcCs|��dS)a-Release the contents of the local for the current context.

    This makes it possible to use locals without a manager.

    With this function one can release :class:`Local` objects as well as
    :class:`StackLocal` objects.  However it's not possible to
    release data held by proxies that way, one always has to retain
    a reference to the underlying local object in order to be able
    to release it.

    Example:
        >>> loc = Local()
        >>> loc.foo = 42
        >>> release_local(loc)
        >>> hasattr(loc, 'foo')
        False
    N)�__release_local__)�localrrr�
release_local^srFc@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)r	z
Local object.)�__storage__�__ident_func__cCs t�|di�t�|dt�dS)NrGrH)�object�__setattr__rr$rrrrxszLocal.__init__cCst|j���Sr")�iterrG�itemsr$rrr�__iter__|szLocal.__iter__cCs
t||�S)zCreate a proxy for a name.r)r�proxyrrr�__call__szLocal.__call__cCs|j�|��d�dSr")rG�poprHr$rrrrD�szLocal.__release_local__cCs4z|j|��|WSty.t|��Yn0dSr"�rGrH�KeyError�AttributeError�rrrrr�__getattr__�szLocal.__getattr__cCsB|��}|j}z||||<Wnty<||i||<Yn0dSr")rHrGrR)rr�value�identZstoragerrrrJ�szLocal.__setattr__cCs4z|j|��|=Wnty.t|��Yn0dSr"rQrTrrr�__delattr__�szLocal.__delattr__N)rr@rArB�	__slots__rrMrOrDrUrJrXrrrrr	ssr	c@sveZdZdZdd�Zdd�Zdd�Zdd	�Zeee�Z	[[d
d�Z
dd
�Zdd�Zdd�Z
edd��Zedd��ZdS)�_LocalStacka�Local stack.

    This class works similar to a :class:`Local` but keeps a stack
    of objects instead.  This is best explained with an example::

        >>> ls = LocalStack()
        >>> ls.push(42)
        >>> ls.top
        42
        >>> ls.push(23)
        >>> ls.top
        23
        >>> ls.pop()
        23
        >>> ls.top
        42

    They can be force released by using a :class:`LocalManager` or with
    the :func:`release_local` function but the correct way is to pop the
    item from the stack after using.  When the stack is empty it will
    no longer be bound to the current context (and as such released).

    By calling the stack without arguments it will return a proxy that
    resolves to the topmost item on the stack.
    cCst�|_dSr")r	�_localr$rrrr�sz_LocalStack.__init__cCs|j��dSr")r[rDr$rrrrD�sz_LocalStack.__release_local__cCs|jjSr")r[rHr$rrr�_get__ident_func__�sz_LocalStack._get__ident_func__cCst�|jd|�dS�NrH)rIrJr[)rrVrrr�_set__ident_func__�sz_LocalStack._set__ident_func__cs�fdd�}t|�S)Ncs�j}|durtd��|S)Nzobject unbound)�top�RuntimeError)�rvr$rr�_lookup�sz%_LocalStack.__call__.<locals>._lookupr)rrbrr$rrO�sz_LocalStack.__call__cCs0t|jdd�}|dur"g|j_}|�|�|S)zPush a new item to the stack.�stackN)�getattrr[rc�append)r�objrarrr�push�s

z_LocalStack.pushcCsDt|jdd�}|durdSt|�dkr8t|j�|dS|��SdS)z�Remove the topmost item from the stack.

        Note:
            Will return the old value or `None` if the stack was already empty.
        rcNr0���)rdr[�lenrFrP�rrcrrrrP�s
z_LocalStack.popcCst|jdd�}|rt|�SdS)Nrcr)rdr[rirjrrr�__len__�sz_LocalStack.__len__cCst|jdd�}|dur|SgS)Nrc)rdr[rjrrrrc�sz_LocalStack.stackc	Cs,z|jjdWSttfy&YdS0dS)ztThe topmost item on the stack.

        Note:
            If the stack is empty, :const:`None` is returned.
        rhN)r[rcrS�
IndexErrorr$rrrr_�sz_LocalStack.topN)rr@rArBrrDr\r^�propertyrHrOrgrPrkrcr_rrrrrZ�s


rZc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)ra�Local objects cannot manage themselves.

    For that you need a local manager.
    You can pass a local manager multiple locals or add them
    later by appending them to ``manager.locals``.  Every time the manager
    cleans up, it will clean up all the data left in the locals for this
    context.

    The ``ident_func`` parameter can be added to override the default ident
    function for the wrapped locals.
    NcCsb|durg|_nt|t�r$|g|_n
t|�|_|durX||_|jD]}t�|d|�qBnt|_dSr])�locals�
isinstancer	�list�
ident_funcrIrJr)rrnrqrErrrrs



zLocalManager.__init__cCs|��S)a4Return context identifier.

        This is the identifier the local objects use internally
        for this context.  You cannot override this method to change the
        behavior but use it to link other context local objects (such as
        SQLAlchemy's scoped sessions) to the Werkzeug locals.
        )rqr$rrrrszLocalManager.get_identcCs|jD]}t|�qdS)z�Manually clean up the data in the locals for this context.

        Call this at the end of the request or use ``make_middleware()``.
        N)rnrF)rrErrr�cleanup$s
zLocalManager.cleanupcCsd�|jjt|j��S)Nz<{} storages: {}>)r(rrrirnr$rrr�__repr__,s�zLocalManager.__repr__)NN)rr@rArBrrrrrsrrrrr�s


rcs0eZdZ�fdd�Zedd��Zdd�Z�ZS)�_FastLocalStackcs(g|_|jj|_|jj|_t���dSr")rcrergrPrrr$r!rrr3s

z_FastLocalStack.__init__c	Cs*z|jdWSttfy$YdS0dS)Nrh)rcrSrlr$rrrr_9sz_FastLocalStack.topcCs
t|j�Sr")rircr$rrrrk@sz_FastLocalStack.__len__)rr@rArrmr_rkrCrrr!rrt1s
rt)"rBr5rr)rr+�
contextlibrrr>Zcelery.localrZgreenletrr�ImportError�_thread�thread�
_dummy_thread�dummy_thread�__all__�environ�getr
r�ThreadrrFr	rZrrErtr
rrrr�<module>sD$
2(d2