/usr/lib/python3/dist-packages/landscape/lib/__pycache__
Edit: /usr/lib/python3/dist-packages/landscape/lib/__pycache__/reactor.cpython-310.pyc (10108B)
o
cl" @ s d Z ddlmZ ddlZddlZddlmZ ddlmZ G dd de Z
G dd d e ZG d
d deZ
G dd
d
eZG dd deZG dd deZdS )zB
Extend the regular Twisted reactor with event-handling features.
)absolute_importN)
deferToThread)
format_objectc @ e Zd ZdZdS ) 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 r c @ r )
CallHookErrorz-Raised when hooking on a reactor incorrectly.Nr r r r r
r r r c @ s e Zd ZdZdd ZdS )EventIDzUnique 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.
c C s || _ || _d S N)_event_type_pair)self
event_typepairr r r
__init__ s
zEventID.__init__N)r r r
r r r r r r
r s r c s: e Zd ZdZ fddZdddZdd 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).
c s t t| i | _d S r )superr r _event_handlersr __class__r r
r - s
z"EventHandlingReactorMixin.__init__r c C s: ||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.
c S s | d S )N r )r r r r
B s z3EventHandlingReactorMixin.call_on..)key)r
setdefaultappendsortr )r r handlerpriorityr handlersr r r
call_on1 s
z!EventHandlingReactorMixin.call_onc O s t d| g }t| j|d}|D ]D\}}zt dt||| |||i | W q tyD t dt|||| | t
yW t dt|||| Y qw t d| |S )ac Fire 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.)loggingdebuglistr getr r" KeyboardInterrupt exceptionstop Exception)r r argskwargsresultsr&