
    af
                        d dl Z d dlZd dlmZ d dlZd dlZe j                            dd          rd dlm	Z	 ej
                            ej        dk     d          ej
                            d	          d
                         Zej
                            ej        dk     d          ej
                            d	          d                         ZdS dS )    NUSE_ASYNCIOF)	Component)      zrequires Python 3.5+)reasonT)forbid_global_loopc                 p  K   t           j        j        | t           j        _        t          ddddg                              |           }| t           j        _        t          j                    fd}t          j        d|           fd	}|                    |            d {V  d S )
Nws://localhost:12/bogus   皙?urlmax_retriesmax_retry_delay
transportsloopc                  n                          t          d                     t          j        _        d S Nz	timed outset_exceptionAssertionErrortxaioconfigr   finished	orig_loops   \/var/www/html/env/lib/python3.11/site-packages/autobahn/wamp/test/test_wamp_component_aio.pyfailz$test_asyncio_component.<locals>.fail;   s/    "">+#>#>??? )EL    g      @c                 j   	 |                                                       t          d                     nJ# t          $ r=}dt	          |          vr"                    t          d                     Y d }~nd }~ww xY w                    d            t          j        _        j	        J d S Nzshould get an errorz(Exhausted all transport connect attemptszwrong exception caught)
resultr   r   RuntimeErrorstr
set_resultr   r   r   _done_f)fecompr   r   s     r   donez$test_asyncio_component.<locals>.done@   s    U


&&~6K'L'LMMMM U U U=SVVKK**>:R+S+STTTU %%% )EL<'''''   6: 
B3A<<B)r   r   r   r   startcreate_future
call_lateradd_done_callback)
event_loopr)   r    r,   r+   r   r   s       @@@r   test_asyncio_componentr3   $   s       L%	& 5#$'* 
 
 
 JJJJ''&&((	* 	* 	* 	* 	* 	* 	d###		( 		( 		( 		( 		( 		( 		( 	
D!!!r!   c                 t  	
K   t           j        j        | t           j        _         G d dt                    } |            	dgd	fd	}t          j                            | d|          5  || _        t          ddd	d
g          }|                    |           }| t           j        _        fd}t          j	        d	|           t          j
                    

fd}t          j	        d|           
fd}|                    |           
 d{V  ddd           dS # 1 swxY w Y   dS )z
        If something connects but then gets aborted, it should still try
        to re-connect (in real cases this could be e.g. wrong path,
        TLS failure, WebSocket handshake failure, etc)
        c                       e Zd Zd Zd ZdS )1test_asyncio_component_404.<locals>.FakeTransportc                     d S N )selfs    r   closez7test_asyncio_component_404.<locals>.FakeTransport.closeY       r!   c                     d S r8   r9   )r:   datas     r   writez7test_asyncio_component_404.<locals>.FakeTransport.write\   r<   r!   N)__name__
__module____qualname__r;   r?   r9   r!   r   FakeTransportr6   X   s2              r!   rC   NFc                     d         : |             }|d<   |                                t          j        |f          S t          j        t	          d                    S )Nr   z"second connection fails completely)connection_mader   create_future_successcreate_future_errorr%   )protocol_factoryserver_hostnamehostportsslprotocolactual_protocolfake_transports         r   create_connectionz5test_asyncio_component_404.<locals>.create_connectionb   sj    q!)++--%-"((8882NH3MNNN0>b1c1cdddr!   rP   r
   r   r   r   r   r   c                  R     d          d                              d            d S d S )Nr   )connection_lost)rN   s   r   nuke_transportz2test_asyncio_component_404.<locals>.nuke_transport   s5    "1%1#A&66t<<<<< 21r!   c                  n                          t          d                     t          j        _        d S r   r   r   s   r   r    z(test_asyncio_component_404.<locals>.fail   s/    &&~k'B'BCCC$-!!!r!   g      ?c                 X   	 |                                                       t          d                     nJ# t          $ r=}dt	          |          vr"                    t          d                     Y d }~nd }~ww xY w                    d            t          j        _        d S r#   )	r$   r   r   r%   r&   r'   r   r   r   )r)   r*   r   r   s     r   r,   z(test_asyncio_component_404.<locals>.done   s    YHHJJJ**>:O+P+PQQQQ# Y Y YAQOO ..~>V/W/WXXXY ##D)))$-!!!r-   )NNNNF)r   r   r   objectmockpatchrP   r   r.   r0   r/   r1   )r2   rC   rP   r+   r)   rS   r    r,   rN   rO   r   r   s           @@@@r   test_asyncio_component_404rY   M   s      L%	&	 	 	 	 	F 	 	 	 '&	e 	e 	e 	e 	e 	e 	e Zz+>@QRR /	 /	+<J(  9'(+.   D 



++A *EL= = = = = S.111*,,H. . . . . . S$'''. . . . . . %%%NNNNNNN_/	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	 /	s   1B/D--D14D1)ossysunittest.mockrW   pytestr   environgetautobahn.asyncio.componentr   markskipifversion_infoasyncior3   rY   r9   r!   r   <module>re      s5  6 
			 



        :>>-'' y444444[(61:PQQ[D11% % 21 RQ%N [(61:PQQ[D11K K 21 RQK K K]y yr!   