
    Ngz
                    \    d dl mZ d dlmZmZ d dlmZ d dlmZ	 erd dl
mZ  G d d      Zy)	    )annotations)TYPE_CHECKINGAny)
dispatcher)signal)Deferredc                  `    e Zd Zej                  fddZd	dZd	dZd
dZ	 	 	 	 	 	 ddZ	ddZ
y)SignalManagerc                    || _         y )N)sender)selfr   s     4lib/python3.12/site-packages/scrapy/signalmanager.py__init__zSignalManager.__init__   s	    !    c                j    |j                  d| j                         t        j                  ||fi | y)a  
        Connect a receiver function to a signal.

        The signal can be any object, although Scrapy comes with some
        predefined signals that are documented in the :ref:`topics-signals`
        section.

        :param receiver: the function to be connected
        :type receiver: collections.abc.Callable

        :param signal: the signal to connect to
        :type signal: object
        r   N)
setdefaultr   r   connectr   receiverr   kwargss       r   r   zSignalManager.connect   s-     	(DKK08V6v6r   c                j    |j                  d| j                         t        j                  ||fi | y)z
        Disconnect a receiver function from a signal. This has the
        opposite effect of the :meth:`connect` method, and the arguments
        are the same.
        r   N)r   r   r   
disconnectr   s       r   r   zSignalManager.disconnect"   s-     	(DKK0h9&9r   c                f    |j                  d| j                         t        j                  |fi |S )z
        Send a signal, catch exceptions and log them.

        The keyword arguments are passed to the signal handlers (connected
        through the :meth:`connect` method).
        r   )r   r   _signalsend_catch_logr   r   r   s      r   r   zSignalManager.send_catch_log+   s.     	(DKK0%%f777r   c                f    |j                  d| j                         t        j                  |fi |S )a  
        Like :meth:`send_catch_log` but supports returning
        :class:`~twisted.internet.defer.Deferred` objects from signal handlers.

        Returns a Deferred that gets fired once all signal handlers
        deferreds were fired. Send a signal, catch exceptions and log them.

        The keyword arguments are passed to the signal handlers (connected
        through the :meth:`connect` method).
        r   )r   r   r   send_catch_log_deferredr   s      r   r   z%SignalManager.send_catch_log_deferred5   s.     	(DKK0..v@@@r   c                h    |j                  d| j                         t        j                  |fi | y)z
        Disconnect all receivers from the given signal.

        :param signal: the signal to disconnect from
        :type signal: object
        r   N)r   r   r   disconnect_allr   s      r   r    zSignalManager.disconnect_allE   s+     	(DKK0v00r   N)r   r   )r   r   r   r   r   r   returnNone)r   r   r   r   r!   zlist[tuple[Any, Any]])r   r   r   r   r!   zDeferred[list[tuple[Any, Any]]])r   r   r   r   r!   r"   )__name__
__module____qualname__r   	Anonymousr   r   r   r   r   r     r   r   r
   r
      sE    %/%9%9 "7":8AA%(A	(A 1r   r
   N)
__future__r   typingr   r   
pydispatchr   scrapy.utilsr   r   twisted.internet.deferr   r
   r'   r   r   <module>r-      s#    " % ! */@1 @1r   