Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/landscape/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/reactor.cpython-310.pyc
o

���cl"�@s�dZddlmZddlZddlZddlmZddlmZGdd�de	�Z
Gdd	�d	e	�ZGd
d�de�Z
Gdd
�d
e�ZGdd�de�ZGdd�de�ZdS)zB
Extend the regular Twisted reactor with event-handling features.
�)�absolute_importN)�
deferToThread)�
format_objectc@�eZdZdZdS)�	InvalidIDz=Raised when an invalid ID is used with reactor.cancel_call().N��__name__�
__module__�__qualname__�__doc__�rr�7/usr/lib/python3/dist-packages/landscape/lib/reactor.pyr�rc@r)�
CallHookErrorz-Raised when hooking on a reactor incorrectly.Nrrrrr
rrrc@seZdZdZdd�ZdS)�EventIDz�Unique identifier for an event handler.

    @param event_type: Name of the event type handled by the handler.
    @param pair: Binary tuple C{(handler, priority)} holding the handler
        function and its priority.
    cCs||_||_dS�N)�_event_type�_pair)�self�
event_type�pairrrr
�__init__s
zEventID.__init__N)rr	r
rrrrrr
rsrcs:eZdZdZ�fdd�Zddd�Zdd�Zd	d
�Z�ZS)�EventHandlingReactorMixina�Fire events identified by strings and register handlers for them.

    Note that event handlers are executed synchronously when the C{fire} method
    is called, so unit-tests can generally exercise events without needing to
    run the real Twisted reactor (except of course if the event handlers
    themselves contain asynchronous calls that need the Twisted reactor
    running).
    cstt|���i|_dSr)�superrr�_event_handlers�r��	__class__rr
r-s
z"EventHandlingReactorMixin.__init__rcCs:||f}|j�|g�}|�|�|jdd�d�t||�S)a�Register an event handler.

        The handler will be invoked every time an event of the given type
        is fired (there's no need to re-register the handler after the
        event is fired).

        @param event_type: The name of the event type to handle.
        @param handler: The function handling the given event type.
        @param priority: The priority of the given handler function.

        @return: The L{EventID} of the registered handler.
        cSs|dS)N�r)rrrr
�<lambda>Bsz3EventHandlingReactorMixin.call_on.<locals>.<lambda>)�key)r�
setdefault�append�sortr)rr�handler�priorityr�handlersrrr
�call_on1s



z!EventHandlingReactorMixin.call_oncOs�t�d|�g}t|j�|d��}|D]D\}}zt�dt|�||�|�||i|���WqtyDt�dt|�|||�|�	��t
yWt�dt|�|||�Yqwt�d|�|S)acFire an event of a given type.

        Call all handlers registered for the given C{event_type}, in order
        of priority.

        @param event_type: The name of the event type to fire.
        @param args: Positional arguments to pass to the registered handlers.
        @param kwargs: Keyword arguments to pass to the registered handlers.
        zStarted firing %s.rz#Calling %s for %s with priority %d.zTKeyboard interrupt while running event handler %s for event type %r with args %r %r.zAError running event handler %s for event type %r with args %r %r.zFinished firing %s.)�logging�debug�listr�getrr"�KeyboardInterrupt�	exception�stop�	Exception)rr�args�kwargs�resultsr&r$r%rrr
�fireFs0

����zEventHandlingReactorMixin.firecCs0t|�tur|j|j�|j�dStd|��)zfUnregister an event handler.

        @param id: the L{EventID} of the handler to unregister.
        z&EventID instance expected, received %rN)�typerrr�removerr�r�idrrr
�cancel_calljsz%EventHandlingReactorMixin.cancel_call)r)	rr	r
rrr'r3r8�
__classcell__rrrr
r#s	
$rc@seZdZdd�ZdS)�	ReactorIDcCs
||_dSr)�_timeout)r�timeoutrrr
rws
zReactorID.__init__N)rr	r
rrrrr
r:usr:cs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Z�ZS)�EventHandlingReactoraWrap and add functionalities to the Twisted reactor.

    This is essentially a facade around the twisted.internet.reactor and
    will delegate to it for mostly everything except event handling features
    which are implemented using EventHandlingReactorMixin.
    csFddlm}ddlm}||_||_|��|j|_tt	|��
�dS)Nr)�reactor)�LoopingCall)�twisted.internetr>�twisted.internet.taskr?�_LoopingCall�_reactor�_cleanup�callFromThreadrr=r)rr>r?rrr
r�szEventHandlingReactor.__init__cCst��S)z5Get current time.

        @see L{time.time}
        )�timerrrr
rF�szEventHandlingReactor.timecOs|jj|i|��S)z�Call a function later.

        Simply call C{callLater(*args, **kwargs)} and return its result.

        @see: L{twisted.internet.interfaces.IReactorTime.callLater}.

        )rC�	callLater)rr0r1rrr
�
call_later�szEventHandlingReactor.call_latercOs*|j|g|�Ri|��}|j|dd�|S)z�Call a function repeatedly.

        Create a new L{twisted.internet.task.LoopingCall} object and
        start it.

        @return: the created C{LoopingCall} object.
        F)�now)rB�start)r�seconds�fr0r1�lcrrr
�
call_every�szEventHandlingReactor.call_everycCsBt|t�rt�||�St||j�r|��S|��r|��dSdS)aCancel a scheduled function or event handler.

        @param id: The function call or handler to remove. It can be an
            L{EventID}, a L{LoopingCall} or a C{IDelayedCall}, as returned
            by L{call_on}, L{call_every} and L{call_later} respectively.
        N)�
isinstancerrr8rBr.�active�cancelr6rrr
r8�s
�z EventHandlingReactor.cancel_callcCs|j�|�dS)zASchedule a function to be called when the reactor starts running.N)rC�callWhenRunning)rrLrrr
�call_when_running�sz&EventHandlingReactor.call_when_runningcOs|jj|g|�Ri|��dS)a1Cause a function to be executed by the reactor thread.

        @param f: The callable object to execute.
        @param args: The arguments to call it with.
        @param kwargs: The keyword arguments to call it with.

        @see: L{twisted.internet.interfaces.IReactorThreads.callFromThread}
        N)rCrE)rrLr0r1rrr
�call_in_main�s	z!EventHandlingReactor.call_in_mainc	sF�fdd�}�fdd�}t|g|�Ri|��}|�|�|�|�dS)a
        Execute a callable object in a new separate thread.

        @param callback: A function to call in case C{f} was successful, it
            will be passed the return value of C{f}.
        @param errback: A function to call in case C{f} raised an exception,
            it will be pass a C{(type, value, traceback)} tuple giving
            information about the raised exception (see L{sys.exc_info}).

        @note: Both C{callback} and C{errback} will be executed in the
            the parent thread.
        cs�r�|�SdSrr)�result)�callbackrr
�
on_success�s�z7EventHandlingReactor.call_in_thread.<locals>.on_successcs6|j|j|jf}�r�|�dStj|d|d�dS)Nr)�exc_info)r4�value�tbr(�error)�failurerX)�errbackrr
�
on_failure�sz7EventHandlingReactor.call_in_thread.<locals>.on_failureN)r�addCallback�
addErrback)	rrVr]rLr0r1rWr^�deferredr)rVr]r
�call_in_thread�s


z#EventHandlingReactor.call_in_threadcCs|jj||dd�S)z!Start listening on a Unix socket.T)�wantPID)rC�
listenUNIX�r�socket�factoryrrr
�listen_unix�sz EventHandlingReactor.listen_unixcCs|j�||�S)zConnect to a Unix socket.)rC�connectUNIXrerrr
�connect_unix�sz!EventHandlingReactor.connect_unixcCs"|�d�|j��|�d�dS)z2Start the reactor, a C{"run"} event will be fired.�runr.N)r3rCrkrrrr
rk�s

zEventHandlingReactor.runcCs|j��|��dS)z2Stop the reactor, a C{"stop"} event will be fired.N)rCr.rDrrrr
r.�s
zEventHandlingReactor.stopcCs$|j��D]
}|��r|��qdSr)rC�getDelayedCallsrPrQ)r�callrrr
rD�s
��zEventHandlingReactor._cleanup)rr	r
rrrFrHrNr8rSrTrbrhrjrkr.rDr9rrrr
r={s	
r=)r�
__future__rr(rF�twisted.internet.threadsr�landscape.lib.formatrr/rr�objectrrr:r=rrrr
�<module>s
R

Spamworldpro Mini