Current File : //proc/self/root/lib/python3/dist-packages/twisted/application/__pycache__/internet.cpython-312.pyc
�

Ϫ�f����dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZmZddlmZdd	lmZdd
lmZd�ZGd�d
ej0�ZGd�de�ZGd�de�ZdZdZGd�de�ZGd�de�ZGd�de�Z Gd�de�Z!Gd�de�Z"Gd�de�Z#Gd �d!e�Z$Gd"�d#e�Z%Gd$�d%e�Z&Gd&�d'e�Z'Gd(�d)e�Z(Gd*�d+ej0�Z)Gd,�d-ej0�Z*Gd.�d/�Z+Gd0�d1�Z,d2d3d4efd5�Z-e-�Z.d6�Z/Gd7�d8�Z0Gd9�d:ej0�Z1gd;�Z2y<)=a�
Reactor-based Services

Here are services to run clients, servers and periodic services using
the reactor.

If you want to run a server service, L{StreamServerEndpointService} defines a
service that can wrap an arbitrary L{IStreamServerEndpoint
<twisted.internet.interfaces.IStreamServerEndpoint>}
as an L{IService}. See also L{twisted.application.strports.service} for
constructing one of these directly from a descriptive string.

Additionally, this module (dynamically) defines various Service subclasses that
let you represent clients and servers in a Service hierarchy.  Endpoints APIs
should be preferred for stream server services, but since those APIs do not yet
exist for clients or datagram services, many of these are still useful.

They are as follows::

  TCPServer, TCPClient,
  UNIXServer, UNIXClient,
  SSLServer, SSLClient,
  UDPServer,
  UNIXDatagramServer, UNIXDatagramClient,
  MulticastServer

These classes take arbitrary arguments in their constructors and pass
them straight on to their respective reactor.listenXXX or
reactor.connectXXX calls.

For example, the following service starts a web server on port 8080:
C{TCPServer(8080, server.Site(r))}.  See the documentation for the
reactor.listen/connect* methods for more information.
�)�random)�List)�MethodicalMachine)�service)�task)�CancelledError�Deferred�fail�
maybeDeferred�succeed)�Logger)�log)�Failurec��|�ddlm}|S|S)zR
    @return: the argument, or the global reactor if the argument is L{None}.
    r)�reactor)�twisted.internetr)�maybeReactorrs  �>/usr/lib/python3/dist-packages/twisted/application/internet.py�_maybeGlobalReactorr<s����,�����c�(�eZdZUgZeeed<d�Zy)�_VolatileDataService�volatilec�v�tjj|�}|jD]
}||vs�||=�|S�N)r�Service�__getstate__r)�self�d�attrs   rrz!_VolatileDataService.__getstate__Ks>���O�O�(�(��.���M�M�	�D��q�y��d�G�	��rN)�__name__�
__module__�__qualname__rr�str�__annotations__r�rrrrHs���H�d�3�i��rrc�L�eZdZUdZdgZdZeed<dZdZ	d�Z
d�Zd�Zd	�Z
d
�Zy)�_AbstractServera
    @cvar volatile: list of attribute to remove from pickling.
    @type volatile: C{list}

    @ivar method: the type of method to call on the reactor, one of B{TCP},
        B{UDP}, B{SSL} or B{UNIX}.
    @type method: C{str}

    @ivar reactor: the current running reactor.
    @type reactor: a provider of C{IReactorTCP}, C{IReactorUDP},
        C{IReactorSSL} or C{IReactorUnix}.

    @ivar _port: instance of port set when the service is started.
    @type _port: a provider of L{twisted.internet.interfaces.IListeningPort}.
    �_port��methodNc�T�||_d|vr|jd�|_||_y�Nr��args�popr�kwargs�rr/r1s   r�__init__z_AbstractServer.__init__j�(����	����!�:�:�i�0�D�L���rc�l�tjj|�|j�|_yr)rr�privilegedStartService�_getPortr)�rs rr6z&_AbstractServer.privilegedStartServiceps!�����.�.�t�4��]�]�_��
rc��tjj|�|j�|j	�|_yyr)rr�startServicer)r7r8s rr:z_AbstractServer.startServicets0�����$�$�T�*��:�:������D�J�rc��tjj|�|j�|jj	�}|`|Syr)rr�stopServicer)�
stopListening)rrs  rr<z_AbstractServer.stopServiceysA�����#�#�D�)��:�:�!��
�
�(�(�*�A��
��H�"rc��tt|j�dj|j��|j
i|j��S)z�
        Wrapper around the appropriate listen method of the reactor.

        @return: the port object returned by the listen method.
        @rtype: an object providing
            L{twisted.internet.interfaces.IListeningPort}.
        zlisten{})�getattrrr�formatr+r/r1r8s rr7z_AbstractServer._getPort�sP��
�w�����-�������
�
�
�9�9�%�
���%�	%r)r!r"r#�__doc__rr+r$r%rr)r3r6r:r<r7r&rrr(r(Ss=��� �y�H��F�C���G��E��%�)�
�
%rr(c�F�eZdZUdZdgZdZeed<dZdZ	d�Z
d�Zd�Zd	�Z
y)
�_AbstractClienta&
    @cvar volatile: list of attribute to remove from pickling.
    @type volatile: C{list}

    @ivar method: the type of method to call on the reactor, one of B{TCP},
        B{UDP}, B{SSL} or B{UNIX}.
    @type method: C{str}

    @ivar reactor: the current running reactor.
    @type reactor: a provider of C{IReactorTCP}, C{IReactorUDP},
        C{IReactorSSL} or C{IReactorUnix}.

    @ivar _connection: instance of connection set when the service is started.
    @type _connection: a provider of L{twisted.internet.interfaces.IConnector}.
    �_connectionr*r+Nc�T�||_d|vr|jd�|_||_yr-r.r2s   rr3z_AbstractClient.__init__�r4rc�l�tjj|�|j�|_yr)rrr:�_getConnectionrDr8s rr:z_AbstractClient.startService�s%�����$�$�T�*��.�.�0��rc��tjj|�|j�|jj	�|`yyr)rrr<rD�
disconnectr8s rr<z_AbstractClient.stopService�s=�����#�#�D�)����'����'�'�)�� �(rc��tt|j�d|j���|ji|j
��S)z�
        Wrapper around the appropriate connect method of the reactor.

        @return: the port object returned by the connect method.
        @rtype: an object providing L{twisted.internet.interfaces.IConnector}.
        �connect)r?rrr+r/r1r8s rrGz_AbstractClient._getConnection�sC��S�w�*�4�<�<�8�G�D�K�K�=�:Q�R�
�Y�Y�
��+�+�
�	
r)r!r"r#rArr+r$r%rrDr3r:r<rGr&rrrCrC�s8��� ��H��F�C���G��K��1�!�	
rrCztConnect to {tran}

Call reactor.connect{tran} when the service starts, with the
arguments given to the constructor.
z�Serve {tran} clients

Call reactor.listen{tran} when the service starts, with the
arguments given to the constructor. When the service stops,
stop listening. See twisted.internet.interfaces for documentation
on arguments to the reactor method.
c�4�eZdZej	d��ZdZy)�	TCPServer�TCP��tranN�r!r"r#�
_serverDocr@rAr+r&rrrMrM�������U��+�G�
�FrrMc�4�eZdZej	d��ZdZy)�	TCPClientrNrON�r!r"r#�
_clientDocr@rAr+r&rrrUrU�rSrrUc�4�eZdZej	d��ZdZy)�
UNIXServer�UNIXrONrQr&rrrYrY�������V��,�G�
�FrrYc�4�eZdZej	d��ZdZy)�
UNIXClientrZrONrVr&rrr]r]�r[rr]c�4�eZdZej	d��ZdZy)�	SSLServer�SSLrONrQr&rrr_r_�rSrr_c�4�eZdZej	d��ZdZy)�	SSLClientr`rONrVr&rrrbrb�rSrrbc�4�eZdZej	d��ZdZy)�	UDPServer�UDPrONrQr&rrrdrd�rSrrdc�4�eZdZej	d��ZdZy)�UNIXDatagramServer�UNIXDatagramrONrQr&rrrgrg�������^��4�G�
�Frrgc�4�eZdZej	d��ZdZy)�UNIXDatagramClientrhrONrVr&rrrkrk�rirrkc�4�eZdZej	d��ZdZy)�MulticastServer�	MulticastrONrQr&rrrmrms�����[��1�G�
�Frrmc�0�eZdZdZddgZd�Zd�Zd�Zd�Zy)	�TimerServicea�
    Service to periodically call a function

    Every C{step} seconds call the given function with the given arguments.
    The service starts the calls when it starts, and cancels them
    when it stops.

    @ivar clock: Source of time. This defaults to L{None} which is
        causes L{twisted.internet.reactor} to be used.
        Feel free to set this to something else, but it probably ought to be
        set *before* calling L{startService}.
    @type clock: L{IReactorTime<twisted.internet.interfaces.IReactorTime>}

    @ivar call: Function and arguments to call periodically.
    @type call: L{tuple} of C{(callable, args, kwargs)}
    �_loop�
_loopFinishedc�4�||_|||f|_d|_y)a+
        @param step: The number of seconds between calls.
        @type step: L{float}

        @param callable: Function to call
        @type callable: L{callable}

        @param args: Positional arguments to pass to function
        @param kwargs: Keyword arguments to pass to function
        N)�step�call�clock)rrt�callabler/r1s     rr3zTimerService.__init__s ����	��t�V�,��	���
rc��tjj|�|j\}}}t	j
|g|��i|��|_t|j�|j_|jj|jd��|_|jj|j�y)NT)�now)rrr:rur�LoopingCallrqrrv�startrtrr�
addErrback�_failed)rrwr/r1s    rr:zTimerService.startService)s������$�$�T�*�!%�����$��
�%�%�h�@��@��@��
�.�t�z�z�:��
�
��!�Z�Z�-�-�d�i�i�T�-�B������%�%�d�l�l�3rc�P�d|j_tj|�y�NF)rq�runningr�err)r�whys  rr}zTimerService._failed5s��#��
�
������rc����jjr�jj��jj	�fd���jS)z�
        Stop the service.

        @rtype: L{Deferred<defer.Deferred>}
        @return: a L{Deferred<defer.Deferred>} which is fired when the
            currently running call (if any) is finished.
        c�B��tjj��Sr)rrr<��_rs �r�<lambda>z*TimerService.stopService.<locals>.<lambda>Fs������1L�1L�T�1R�r)rqr��stoprr�addCallbackr8s`rr<zTimerService.stopService<sA����:�:����J�J�O�O�����&�&�'R�S��!�!�!rN)	r!r"r#rArr3r:r}r<r&rrrprps'���"��)�H�
�
4��"rrpc�(�eZdZdZd�Zd�Zd�Zd�Zy)�CooperatorServicezb
    Simple L{service.IService} which starts and stops a L{twisted.internet.task.Cooperator}.
    c�:�tjd��|_y)NF)�started)r�
Cooperator�coopr8s rr3zCooperatorService.__init__Os���O�O�E�2��	rc�8�|jj|�Sr)r��	coiterate)r�iterators  rr�zCooperatorService.coiterateRs���y�y�"�"�8�,�,rc�8�|jj�yr)r�r{r8s rr:zCooperatorService.startServiceUs���	�	���rc�8�|jj�yr)r�r�r8s rr<zCooperatorService.stopServiceXs���	�	���rN)r!r"r#rAr3r�r:r<r&rrr�r�Js���3�-��rr�c�,�eZdZdZdZd�Zd�Zd�Zd�Zy)�StreamServerEndpointServiceaP
    A L{StreamServerEndpointService} is an L{IService} which runs a server on a
    listening port described by an L{IStreamServerEndpoint
    <twisted.internet.interfaces.IStreamServerEndpoint>}.

    @ivar factory: A server factory which will be used to listen on the
        endpoint.

    @ivar endpoint: An L{IStreamServerEndpoint
        <twisted.internet.interfaces.IStreamServerEndpoint>} provider
        which will be used to listen when the service starts.

    @ivar _waitingForPort: a Deferred, if C{listen} has yet been invoked on the
        endpoint, otherwise None.

    @ivar _raiseSynchronously: Defines error-handling behavior for the case
        where C{listen(...)} raises an exception before C{startService} or
        C{privilegedStartService} have completed.

    @type _raiseSynchronously: C{bool}

    @since: 10.2
    Fc�.�||_||_d|_yr)�endpoint�factory�_waitingForPort)rr�r�s   rr3z$StreamServerEndpointService.__init__ws�� ��
����#��rc����tjj���jj	�j
��_g���fd�}�jj|��r�dj�d�_	y)z2
        Start listening on the endpoint.
        c����jr�j|�y|jt�st	j
|�yyr)�_raiseSynchronously�append�checkrrr�)r��	raisedNowrs ��r�handleItzDStreamServerEndpointService.privilegedStartService.<locals>.handleIt�s6����'�'�� � ��%��Y�Y�~�.������/rrFN)
rrr6r��listenr�r�r|�raiseExceptionr�)rr�r�s` @rr6z2StreamServerEndpointService.privilegedStartService|sm���	���.�.�t�4�#�}�}�3�3�D�L�L�A����	�	�	
���'�'��1���a�L�'�'�)�#(�� rc�|�tjj|�|j�|j	�yy)zu
        Start listening on the endpoint, unless L{privilegedStartService} got
        around to it already.
        N)rrr:r�r6r8s rr:z(StreamServerEndpointService.startService�s3��
	���$�$�T�*����'��'�'�)�(rc����jj�d�}�jj|�}�fd�}|j|�|S)a
        Stop listening on the port if it is already listening, otherwise,
        cancel the attempt to listen.

        @return: a L{Deferred<twisted.internet.defer.Deferred>} which fires
            with L{None} when the port has stopped listening.
        c�(�|�|j�Syr)r=)�ports r�stopItz7StreamServerEndpointService.stopService.<locals>.stopIt�s�����)�)�+�+� rc���d�_|Sr)r�)�passthroughrs �rr�z5StreamServerEndpointService.stopService.<locals>.stop�s��� �D�L��r)r��cancelr��addBoth)rr�rr�s`   rr<z'StreamServerEndpointService.stopService�sK���	
���#�#�%�	,�
� � �,�,�V�4��	�	
�	�	�$���rN)	r!r"r#rAr�r3r6r:r<r&rrr�r�\s#���0 ��$�
)�&*�rr�c�.�eZdZdZd�Zd�Zd�Zdefd�Zy)�_ReconnectingProtocolProxyz�
    A proxy for a Protocol to provide connectionLost notification to a client
    connection service, in support of reconnecting when connections are lost.
    c� �||_||_y)a�
        Create a L{_ReconnectingProtocolProxy}.

        @param protocol: the application-provided L{interfaces.IProtocol}
            provider.
        @type protocol: provider of L{interfaces.IProtocol} which may
            additionally provide L{interfaces.IHalfCloseableProtocol} and
            L{interfaces.IFileDescriptorReceiver}.

        @param lostNotification: a 1-argument callable to invoke with the
            C{reason} when the connection is lost.
        N)�	_protocol�_lostNotification)r�protocol�lostNotifications   rr3z#_ReconnectingProtocolProxy.__init__�s��"���!1��rc��	|jj|�|j|�S#|j|�wxYw)z�
        The connection was lost.  Relay this information.

        @param reason: The reason the connection was lost.

        @return: the underlying protocol's result
        )r��connectionLostr�)r�reasons  rr�z)_ReconnectingProtocolProxy.connectionLost�s6��	+��>�>�0�0��8��"�"�6�*��D�"�"�6�*�s	�.�Ac�.�t|j|�Sr)r?r��r�items  r�__getattr__z&_ReconnectingProtocolProxy.__getattr__�s���t�~�~�t�,�,r�returnc�P�d|jj�d|j�d�S)N�<z
 wrapping �>)�	__class__r!r�r8s r�__repr__z#_ReconnectingProtocolProxy.__repr__�s'���4�>�>�*�*�+�:�d�n�n�5G�q�I�IrN)	r!r"r#rAr3r�r�r$r�r&rrr�r��s$���
2� +�-�J�#�Jrr�c�.�eZdZdZd�Zd�Zd�Zdefd�Zy)�_DisconnectFactoryz�
    A L{_DisconnectFactory} is a proxy for L{IProtocolFactory} that catches
    C{connectionLost} notifications and relays them.
    c� �||_||_yr)�_protocolFactory�_protocolDisconnected)r�protocolFactory�protocolDisconnecteds   rr3z_DisconnectFactory.__init__�s�� /���%9��"rc�`�t|jj|�|j�S)a2
        Create a L{_ReconnectingProtocolProxy} with the disconnect-notification
        callback we were called with.

        @param addr: The address the connection is coming from.

        @return: a L{_ReconnectingProtocolProxy} for a protocol produced by
            C{self._protocolFactory}
        )r�r��
buildProtocolr�)r�addrs  rr�z _DisconnectFactory.buildProtocol�s-��*��!�!�/�/��5�t�7Q�7Q�
�	
rc�.�t|j|�Sr)r?r�r�s  rr�z_DisconnectFactory.__getattr__�s���t�,�,�d�3�3rr�c�b�dj|jj|j�S)Nz<{} wrapping {!r}>)r@r�r!r�r8s rr�z_DisconnectFactory.__repr__�s*��#�*�*��N�N�#�#�T�%:�%:�
�	
rN)	r!r"r#rAr3r�r�r$r�r&rrr�r��s"���
:�
�4�
�#�
rr�g�?gN@g�?c����������fd�}|S)a�
    A timeout policy for L{ClientService} which computes an exponential backoff
    interval with configurable parameters.

    @since: 16.1.0

    @param initialDelay: Delay for the first reconnection attempt (default
        1.0s).
    @type initialDelay: L{float}

    @param maxDelay: Maximum number of seconds between connection attempts
        (default 60 seconds, or one minute).  Note that this value is before
        jitter is applied, so the actual maximum possible delay is this value
        plus the maximum possible result of C{jitter()}.
    @type maxDelay: L{float}

    @param factor: A multiplicative factor by which the delay grows on each
        failed reattempt.  Default: 1.5.
    @type factor: L{float}

    @param jitter: A 0-argument callable that introduces noise into the delay.
        By default, C{random.random}, i.e. a pseudorandom floating-point value
        between zero and one.
    @type jitter: 0-argument callable returning L{float}

    @return: a 1-argument callable that, given an attempt count, returns a
        floating point number; the number of seconds to delay.
    @rtype: see L{ClientService.__init__}'s C{retryPolicy} argument.
    c�t��	t��td|�zz��}|��zS#t$r�}Y�wxYw)N�d)�min�
OverflowError)�attempt�delay�factor�initialDelay�jitter�maxDelays  ����r�policyzbackoffPolicy.<locals>.policysJ���	����#�c�7�2C�(C�D�h�O�E��v�x�����	��E�	�s�)�7�7r&)r�r�r�r�r�s```` r�
backoffPolicyr��s���B ��Mrc��t|�dS)aO
    Return the first element of a generator and exhaust it.

    C{MethodicalMachine.upon}'s C{collector} argument takes a generator of
    output results. If the generator is exhausted, the later outputs aren't
    actually run.

    @param gen: Generator to extract values from

    @return: The first element of the generator.
    r)�list)�gens r�_firstResultr�)s����9�Q�<�rc�
�eZdZdZe�Zd�Zejd��d��Zej�d��Z	ej�d��Z
ej�d��Zej�d	��Zej�d
��Z
ej�d��Zej�d��Zej#�d
��Zd�Zej#�d��Zej�d��Zej#�d��Zej#�d��Zej#�d��Zej#�d��Zej�d��Zej#�d��Zej�d��Zej#�d��Zej#�d��Zd�Zej�d��Z ej�d��Z!ej#�d��Z"ej#�d��Z#ej#�d��Z$ej#�d ��Z%ej#�d!��Z&d"�Z'ej�d-d$��Z(ej#�d-d%��Z)ej#�d-d&��Z*ej#�d-d'��Z+ej#�d(��Z,d)�Z-ej#�d*��Z.ej_ee	eg�+�ej_eee,ge0�,�e	j_ee	g�+�e	j_eeeege0�,�e	j_eeeg�+�e	j_ee
ee.g�+�e
j_ee
g�+�e
j_eeee#ee%ge0�,�e
j_e e	eg�+�ej_eeg�+�ej_eeeege0�,�ej_e!e
e"eg�+�ej_ee
eg�+�ej_eeege0�,�ej_e!ee#e%e"g�+�ej_eee$e&g�+�e
j_ee
g�+�e
j_eeege0�,�e
j_e!e	e%eg�+�ej_ee	eg�+�ej_eee,ge0�,�ej_e(ee+ge0�,�e	j_e(e	e+ge0�,�e
j_e(e
e+ge0�,�ej_e(ee)ge0�,�ej_e(ee+ge0�,�e
j_e(e
e+ge0�,�ej_e(ee*ge0�,�y#).�_ClientMachinea
    State machine for maintaining a single outgoing connection to an endpoint.

    @ivar _awaitingConnected: notifications to make when connection
        succeeds, fails, or is cancelled
    @type _awaitingConnected: list of (Deferred, count) tuples

    @see: L{ClientService}
    c��||_d|_d|_||_||_||_||_td�|_g|_	g|_
||_y)z�
        @see: L{ClientService.__init__}

        @param log: The logger for the L{ClientService} instance this state
            machine is associated to.
        @type log: L{Logger}
        rFN)�	_endpoint�_failedAttempts�_stopped�_factory�_timeoutForAttempt�_clock�_prepareConnectionr�_connectionInProgress�_awaitingConnected�_stopWaiters�_log)rr�r��retryPolicyrv�prepareConnectionrs       rr3z_ClientMachine.__init__Es[��"��� �����
���
�"-������"3���%,�T�]��"�"$��������	rT)�initialc��y)z3
        The service has not been started.
        Nr&r8s r�_initz_ClientMachine._init[��rc��y)z5
        The service has started connecting.
        Nr&r8s r�_connectingz_ClientMachine._connectingar�rc��y)za
        The service is waiting for the reconnection period
        before reconnecting.
        Nr&r8s r�_waitingz_ClientMachine._waitinggr�rc��y)z+
        The service is connected.
        Nr&r8s r�
_connectedz_ClientMachine._connectednr�rc��y)zM
        The service is disconnecting after being asked to shutdown.
        Nr&r8s r�_disconnectingz_ClientMachine._disconnectingtr�rc��y)zM
        The service is disconnecting and has been asked to restart.
        Nr&r8s r�_restartingz_ClientMachine._restartingzr�rc��y)zC
        The service has been stopped and is disconnected.
        Nr&r8s rr�z_ClientMachine._stopped�r�rc��y)�T
        Start this L{ClientService}, initiating the connection retry loop.
        Nr&r8s rr{z_ClientMachine.start�r�rc���t�j�fd��}�jj|�j	�j
�j	�j�j�j��_	y)z-
        Start a connection attempt.
        c�$���j�Sr)�_clientDisconnectedr�s �rr�z)_ClientMachine._connect.<locals>.<lambda>�s���T�%=�%=�%?�rN)
r�r�r�rKr��_runPrepareConnection�_connectionMader|�_connectionFailedr�)r�factoryProxys` r�_connectz_ClientMachine._connect�se���
*��M�M�?�
��

�N�N�"�"�<�0�
�[��3�3�
4�
�[��-�-�
.�
�Z��.�.�
/�		
�"rc�p��|jr(t|j��j�fd��S�S)am
        Run any C{prepareConnection} callback with the connected protocol,
        ignoring its return value but propagating any failure.

        @param protocol: The protocol of the connection.
        @type protocol: L{IProtocol}

        @return: Either:

            - A L{Deferred} that succeeds with the protocol when the
              C{prepareConnection} callback has executed successfully.

            - A L{Deferred} that fails when the C{prepareConnection} callback
              throws or returns a failed L{Deferred}.

            - The protocol, when no C{prepareConnection} callback is defined.
        c����Srr&)r�r�s �rr�z6_ClientMachine._runPrepareConnection.<locals>.<lambda>�s���(�r)r�rr��rr�s `rrz$_ClientMachine._runPrepareConnection�s8���$�"�"� ��!8�!8�(�C�O�O�"��
��rc��d|_y)z6
        Reset the number of failed attempts.
        rN)r�r8s r�_resetFailedAttemptsz#_ClientMachine._resetFailedAttempts�s��
 !��rc��y)z�
        Stop trying to connect and disconnect any current connection.

        @return: a L{Deferred} that fires when all outstanding connections are
            closed and all in-progress connection attempts halted.
        Nr&r8s rr�z_ClientMachine.stop�r�rc�f�|jjt��|jdS)z�
        Return a deferred that will fire when the service has finished
        disconnecting.

        @return: L{Deferred} that fires when the service has finished
            disconnecting.
        ���)r�r�r	r8s r�_waitForStopz_ClientMachine._waitForStop�s+��	
��� � ���,�� � ��$�$rc�8�|jj�y)z2
        Stop pending connection attempt.
        N)r�r�r8s r�_stopConnectingz_ClientMachine._stopConnecting�s��
	
�"�"�)�)�+rc�<�|jj�|`y)z4
        Stop pending attempt to reconnect.
        N)�
_retryCallr�r8s r�
_stopRetryingz_ClientMachine._stopRetrying�s��
	
����� ��Orc�L�|jjj�y)z4
        Disconnect the current connection.
        N)�_currentConnection�	transport�loseConnectionr8s r�_disconnectz_ClientMachine._disconnect�s��
	
���)�)�8�8�:rc��y)z�
        A connection has been made.

        @param protocol: The protocol of the connection.
        @type protocol: L{IProtocol}
        Nr&r	s  rrz_ClientMachine._connectionMade�r�rc�j�d|_|j|_|j|j�y)z�
        Notify all pending requests for a connection that a connection has been
        made.

        @param protocol: The protocol of the connection.
        @type protocol: L{IProtocol}
        rN)r�r�r�_unawaitr	s  r�_notifyWaitersz_ClientMachine._notifyWaiters�s,�� !���"*�"4�"4����
�
�d�-�-�.rc��y)z8
        The current connection attempt failed.
        Nr&�r�fs  rrz _ClientMachine._connectionFailed�r�rc�$�|j�y)z+
        Schedule a retry attempt.
        N��_doWaitr8s r�_waitz_ClientMachine._waits
��
	
���rc�"�|j�S)zM
        Schedule a retry attempt, and ignore the Failure passed in.
        r"rs  r�_ignoreAndWaitz_ClientMachine._ignoreAndWaits��
�|�|�~�rc� �|xjdz
c_|j|j�}|jjd|j|j|��|j
j
||j�|_y)N�zDScheduling retry {attempt} to connect {endpoint} in {delay} seconds.)r�r�r�)	r�r�r��infor�r��	callLater�
_reconnectr)rr�s  rr#z_ClientMachine._doWaitsr������!���'�'��(<�(<�=���	�	���U��(�(��^�^��		�	
��+�+�/�/��t���G��rc��y)z?
        The wait between connection attempts is done.
        Nr&r8s rr+z_ClientMachine._reconnectr�rc��y)z?
        The current connection has been disconnected.
        Nr&r8s rrz"_ClientMachine._clientDisconnected$r�rc��|`y)z0
        Forget the current connection.
        N)rr8s r�_forgetConnectionz _ClientMachine._forgetConnection*s
��

�#rc�H�|jtt���y)zm
        Notify all pending requests for a connection that no more connections
        are expected.
        N�rrrr8s r�_cancelConnectWaitersz$_ClientMachine._cancelConnectWaiters1���	
�
�
�g�n�.�/�0rc�H�|jtt���y)z�
        Notify all pending requests for a connection that no more connections
        are expected, after ignoring the Failure passed in.
        Nr1rs  r�_ignoreAndCancelConnectWaitersz-_ClientMachine._ignoreAndCancelConnectWaiters9r3rc�$�|j�y)zG
        Notify all deferreds waiting on the service stopping.
        N��_doFinishStoppingr8s r�_finishStoppingz_ClientMachine._finishStoppingAs��
	
��� rc�$�|j�y)zq
        Notify all deferreds waiting on the service stopping, and ignore the
        Failure passed in.
        Nr7rs  r�_ignoreAndFinishStoppingz'_ClientMachine._ignoreAndFinishStoppingHs��	
��� rc�\�g|jc|_}|D]}|jd��yr)r��callback)r�waiting�ws   rr8z _ClientMachine._doFinishStoppingPs2��%'��):�):�"���7��	�A�
�J�J�t��	rNc��y)�i
        Retrieve the currently-connected L{Protocol}, or the next one to
        connect.

        @param failAfterFailures: number of connection failures after which
            the Deferred will deliver a Failure (None means the Deferred will
            only fail if/when the service is stopped).  Set this to 1 to make
            the very first connection failure signal an error.  Use 2 to
            allow one failure but signal an error if the subsequent retry
            then fails.
        @type failAfterFailures: L{int} or None

        @return: a Deferred that fires with a protocol produced by the
            factory passed to C{__init__}
        @rtype: L{Deferred} that may:

            - fire with L{IProtocol}

            - fail with L{CancelledError} when the service is stopped

            - fail with e.g.
              L{DNSLookupError<twisted.internet.error.DNSLookupError>} or
              L{ConnectionRefusedError<twisted.internet.error.ConnectionRefusedError>}
              when the number of consecutive failed connection attempts
              equals the value of "failAfterFailures"
        Nr&�r�failAfterFailuress  r�
whenConnectedz_ClientMachine.whenConnectedUr�rc�,�t|j�S)z�
        Return the currently connected protocol.

        @return: L{Deferred} that is fired with currently connected protocol.
        )rrrBs  rrz!_ClientMachine._currentConnectionrs���t�.�.�/�/rc�(�tt��S)z�
        Notify the caller that no connection is expected.

        @return: L{Deferred} that is fired with L{CancelledError}.
        )r
rrBs  r�
_noConnectionz_ClientMachine._noConnection{s���N�$�%�%rc�T�t�}|jj||f�|S)z�
        Return a deferred that will fire with the next connected protocol.

        @return: L{Deferred} that will fire with the next connected protocol.
        )r	r�r�)rrC�results   r�_awaitingConnectionz"_ClientMachine._awaitingConnection�s*��������&�&��0A�'B�C��
rc��td�S)z�
        Return a deferred that has already fired with L{None}.

        @return: A L{Deferred} that has already fired with L{None}.
        N)rr8s r�_deferredSucceededWithNonez)_ClientMachine._deferredSucceededWithNone�s���t�}�rc�b�g|jc|_}|D]\}}|j|��y)z�
        Fire all outstanding L{ClientService.whenConnected} L{Deferred}s.

        @param value: the value to fire the L{Deferred}s with.
        N)r�r=)r�valuer>r?�	remainings     rrz_ClientMachine._unawait�s8��,.�t�/F�/F�(����#�	�L�A�y�
�J�J�u��	rc��g}g}|jD]H\}}|�|j||f��|dkr|j|��3|j||dz
f��J||_|D]}|j|��y)z�
        Deliver connection failures to any L{ClientService.whenConnected}
        L{Deferred}s that have met their failAfterFailures threshold.

        @param f: the Failure to fire the L{Deferred}s with.
        Nr()r�r�r=)rr �ready�notReadyr?rOs      r�_deliverConnectionFailurez(_ClientMachine._deliverConnectionFailure�s������� �3�3�	4�L�A�y�� �����I��/��a�����Q������I��M� 2�3�
	4�#+����	�A�
�J�J�q�M�	r)�enter�outputs)rTrU�	collectorr)1r!r"r#rAr�_machiner3�stater�r�r�r�r�r�r��inputr{�outputrrrr�rrrrrrrr$r&r#r+rr/r2r5r9r;r8rDrrGrJrLrrS�uponr�r&rrr�r�8s����!�"�H��,�^�^�D�^�!��"��
�^�^�����
�^�^������^�^�����
�^�^�����
�^�^�����
�^�^�����
�^�^�����
�_�_��

��

��0�_�_��!��!��^�^������_�_��	%��	%��_�_��,��,��_�_������_�_��;��;��^�^������_�_��
/��
/��^�^�����
�_�_������_�_�����	H��^�^�����
�^�^�����
�_�_��$��$��_�_��1��1��_�_��1��1��_�_��!��!��_�_��!��!��
�^�^�����8�_�_��0��0��_�_��&��&��_�_������_�_�������_�_�����,
�J�J�u�K�(��J�<�	�J�J���+�,��	�����U�+�r��:��������/��	�����_�J��@P��Q�������!:�;���
�M�M�%�x��M�4��M�M����4�m�_�U��	��
�M�M�*�K�(��M�D��O�O�E��R�O�8��O�O����{�+��	���O�O��8�6G��5O�������[�;O�:P��Q�����N�\�N�l��������&��9J�K��������/�1I�J������U�+�r��:�����N�\�N�l�������;��(�8S���
�M�M�%�{�X�J�M�?��M�M���+�,��	��
�J�J���$�%��	�������$�%��	��
�M�M���$�%��	���O�O���#�$��	�������$�%��	�������$�%��	��
�M�M��X�
��,��rr�c�L��eZdZdZe�Z	dd�Zdd�Z�fd�Z�fd�Z	�xZ
S)�
ClientServicez�
    A L{ClientService} maintains a single outgoing connection to a client
    endpoint, reconnecting after a configurable timeout when a connection
    fails, either before or after connecting.

    @since: 16.1.0
    c�n�t|�}|�tn|}t||||||j��|_y)aZ
        @param endpoint: A L{stream client endpoint
            <interfaces.IStreamClientEndpoint>} provider which will be used to
            connect when the service starts.

        @param factory: A L{protocol factory <interfaces.IProtocolFactory>}
            which will be used to create clients for the endpoint.

        @param retryPolicy: A policy configuring how long L{ClientService} will
            wait between attempts to connect to C{endpoint}.
        @type retryPolicy: callable taking (the number of failed connection
            attempts made in a row (L{int})) and returning the number of
            seconds to wait before making another attempt.

        @param clock: The clock used to schedule reconnection.  It's mainly
            useful to be parametrized in tests.  If the factory is serialized,
            this attribute will not be serialized, and the default value (the
            reactor) will be restored when deserialized.
        @type clock: L{IReactorTime}

        @param prepareConnection: A single argument L{callable} that may return
            a L{Deferred}. It will be called once with the L{protocol
            <interfaces.IProtocol>} each time a new connection is made.  It may
            call methods on the protocol to prepare it for use (e.g.
            authenticate) or validate it (check its health).

            The C{prepareConnection} callable may raise an exception or return
            a L{Deferred} which fails to reject the connection.  A rejected
            connection is not used to fire an L{Deferred} returned by
            L{whenConnected}.  Instead, L{ClientService} handles the failure
            and continues as if the connection attempt were a failure
            (incrementing the counter passed to C{retryPolicy}).

            L{Deferred}s returned by L{whenConnected} will not fire until
            any L{Deferred} returned by the C{prepareConnection} callable
            fire. Otherwise its successful return value is consumed, but
            ignored.

            Present Since Twisted 18.7.0

        @type prepareConnection: L{callable}

        N)r�r)r�_defaultPolicyr�r�rW)rr�r�r�rvr�s      rr3zClientService.__init__:s=��\$�E�*��(3�(;�n���&�����/��	�	�

��
rc�8�|jj|�S)rA)rWrDrBs  rrDzClientService.whenConnectedts��6�}�}�*�*�+<�=�=rc���|jr|jjd�yt�|��|j
j
�y)r�z1Duplicate ClientService.startService {log_source}N)r�r��warn�superr:rWr{�rr�s �rr:zClientService.startService�s;����<�<��I�I�N�N�N�O��
�����
�
���rc�T��t�|��|jj�S)z�
        Stop attempting to reconnect and close any existing connections.

        @return: a L{Deferred} that fires when all outstanding connections are
            closed and all in-progress connection attempts halted.
        )rcr<rWr�rds �rr<zClientService.stopService�s#���	�����}�}�!�!�#�#r)NNNr)r!r"r#rAr
r�r3rDr:r<�
__classcell__)r�s@rr]r]/s2�����8�D�RV�8
�t>�:�$�$rr])rpr�rmr�rdr]rMrUrYr]r_rbrgrkN)3rAr�_goodEnoughRandom�typingr�automatr�twisted.applicationrrr�twisted.internet.deferrr	r
rr�twisted.loggerr
�twisted.pythonr�twisted.python.failurerrrrr(rCrWrRrMrUrYr]r_rbrdrgrkrmrpr�r�r�r�r�r_r�r�r]�__all__r&rr�<module>rpsz��
!�H/��%�'�!���"��*�	��7�?�?��<%�*�<%�~0
�*�0
�f�
��
����
���
���
���
���
���
���
���
���
�o��
A"�'�A"�H�����$Q�'�/�/�Q�h'J�'J�T
�
�D�t�C�8I�(�V����t�t�nt$�G�O�O�t$�n�r
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!