� j f؆�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkreed��ndd�ZGdd�dej�Zeed�r�dd�Znddl Z dd�ZGdd �d ej!�Z"Gd!d"�d"ej#ej$�Z%eed#�rej&Z'nddl Z d$d%�Z'Gd&d'�d'e j(�Z)Gd(d�d�Z*Gd)d*�d*e*�Z+Gd+d�de+�Z,Gd,d�de+�Z-Gd-d.�d.ej.�Z/eZ0e/Z1dS)/z2Selector event loop for Unix with signal handling.�N�)� base_events)�base_subprocess)�compat)� constants)� coroutines)�events)�futures)�selector_events)� selectors)� transports)� coroutine)�logger�SelectorEventLoop�AbstractChildWatcher�SafeChildWatcher�FastChildWatcher�DefaultEventLoopPolicy�win32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N�)�signumZframerr�8/opt/alt/python34/lib64/python3.4/asyncio/unix_events.py�_sighandler_noop%src seZdZdZd�fdd�Zdd�Z�fdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dddd�Z dddd�Z eddd��Zdd�Zedddddddd��Zedddd d!ddd"d#��Z�S)$�_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncst�j|�i|_dS)N)�super�__init__�_signal_handlers)�selfZselector)� __class__rrr0sz_UnixSelectorEventLoop.__init__cCs tj�S)N)�socketZ socketpair)rrrr� _socketpair4sz"_UnixSelectorEventLoop._socketpaircs8t�j�x$t|j�D]}|j|�qWdS)N)r�close�listr�remove_signal_handler)r�sig)rrrr!7s z_UnixSelectorEventLoop.closecCs.x'|D]}|sqn|j|�qWdS)N)�_handle_signal)r�datarrrr�_process_self_data<s z)_UnixSelectorEventLoop._process_self_datac+Gs�tj|�stj|�r-td��n|j|�|j�ytj|jj ��Wn=t t fk r�}zt t |���WYdd}~XnXtj|||�}||j|<y$tj|t�tj|d�Wn�t k r�}z�|j|=|js^ytjd�Wq^t t fk rZ}ztjd|�WYdd}~Xq^Xn|jtjkr�t dj|���n�WYdd}~XnXdS)z�Add a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught���)rZ iscoroutineZiscoroutinefunction� TypeError� _check_signalZ _check_closed�signal� set_wakeup_fdZ_csock�fileno� ValueError�OSError� RuntimeError�strrZHandlerr� siginterruptr�info�errno�EINVAL�format)rr$�callback�args�exc�handleZnexcrrr�add_signal_handlerCs0  %   &z)_UnixSelectorEventLoop.add_signal_handlercCsL|jj|�}|dkr"dS|jr;|j|�n |j|�dS)z2Internal helper that is the actual signal handler.N)r�getZ _cancelledr#Z_add_callback_signalsafe)rr$r:rrrr%ps   z%_UnixSelectorEventLoop._handle_signalc&Cs |j|�y|j|=Wntk r3dSYnX|tjkrOtj}n tj}ytj||�WnRtk r�}z2|jtj kr�t dj |���n�WYdd}~XnX|jsytj d�Wqt tfk r}ztjd|�WYdd}~XqXndS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr()r*r�KeyErrorr+�SIGINT�default_int_handler�SIG_DFLr/r4r5r0r6r,r.rr3)rr$Zhandlerr9rrrr#zs(      &z,_UnixSelectorEventLoop.remove_signal_handlercCsht|t�s'tdj|���nd|koAtjknsdtdj|tj���ndS)z�Internal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N)� isinstance�intr)r6r+�NSIGr.)rr$rrrr*�s z$_UnixSelectorEventLoop._check_signalcCst|||||�S)N)�_UnixReadPipeTransport)r�pipe�protocol�waiter�extrarrr�_make_read_pipe_transport�sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||�S)N)�_UnixWritePipeTransport)rrErFrGrHrrr�_make_write_pipe_transport�sz1_UnixSelectorEventLoop._make_write_pipe_transportc ks�tj���} tjd|�} t||||||||d| d|| �} | j| j�|j| �y | DdHWn+tk r�} z | }WYdd} ~ XnXd}|dk r�| j �| j �DdH|�nWdQX| S)N�looprGrH) r�get_child_watcherr ZFuture�_UnixSubprocessTransport�add_child_handlerZget_pid�_child_watcher_callback� Exceptionr!Z_wait)rrFr8�shell�stdin�stdout�stderr�bufsizerH�kwargs�watcherrG�transpr9�errrrr�_make_subprocess_transport�s$      z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|�dS)N)Zcall_soon_threadsafeZ_process_exited)r�pid� returncoderYrrrrP�sz._UnixSelectorEventLoop._child_watcher_callback�ssl�sock�server_hostnamec cs8|dks!t|t�s!t�|rE|dkr`td��q`n|dk r`td��n|dk r�|dk r�td��ntjtjtjd�}y&|jd�|j||�DdHWq |j ��Yq Xn(|dkr�td��n|jd�|j ||||�DdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specified) rAr1�AssertionErrorr.r�AF_UNIX� SOCK_STREAM� setblockingZ sock_connectr!Z_create_connection_transport)r�protocol_factory�pathr^r_r`� transportrFrrr�create_unix_connection�s0!          z-_UnixSelectorEventLoop.create_unix_connection�backlog�dc Cs�t|t�rtd��n|dk r�|dk rEtd��ntjtjtj�}y|j|�Wq8tk r�}zK|j �|j t j kr�dj |�}tt j |�d�n�WYdd}~Xq8|j ��Yq8XnE|dkrtd��n|j tjkr8tdj |���ntj||g�}|j|�|jd�|j||||�|S)Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timezAddress {!r} is already in usez-path was not specified, and no sock specifiedz+A UNIX Domain Socket was expected, got {!r}F)rA�boolr)r.rrbrcZbindr/r!r4Z EADDRINUSEr6ZfamilyrZServerZlistenrdZ_start_serving) rrerfr_rir^r9�msgZserverrrr�create_unix_server�s:          z)_UnixSelectorEventLoop.create_unix_server)�__name__� __module__� __qualname__�__doc__rr r!r'r;r%r#r*rIrKr r[rPrhrmrr)rrr*s,    -    r� set_blockingcCstj|d�dS)NF)�osrr)�fdrrr�_set_nonblockingsrucCs<tj|tj�}|tjB}tj|tj|�dS)N)�fcntlZF_GETFLrs� O_NONBLOCKZF_SETFL)rt�flagsrrrru$s cs�eZdZdZdd�fdd�Zdd�Zdd �Zd d �Zd d �Zdd�Z dd�Z e j r�dd�Z nddd�Zdd�Zdd�Z�S)rD�iNcst�j|�||jd<||_||_|j�|_tj|j�j }t j |�p}t j |�p}t j |�s�td��nt|j�||_d|_|jj|jj|�|jj|jj|j|j�|dk r|jjtj|d�ndS)NrEz)Pipe transport is for pipes/sockets only.F)rr�_extra�_loop�_piper-�_filenors�fstat�st_mode�stat�S_ISFIFO�S_ISSOCK�S_ISCHRr.ru� _protocol�_closing� call_soon�connection_made� add_reader� _read_readyr �_set_result_unless_cancelled)rrLrErFrGrH�mode)rrrr.s&       z_UnixReadPipeTransport.__init__cCs�|jjg}|jdkr.|jd�n|jrG|jd�n|jd|j�|jdk r�tj|jj |jt j �}|r�|jd�q�|jd�n |jd�ddj |�S)N�closed�closingzfd=%s�polling�idlez<%s>� ) rrnr|�appendr�r}r �_test_selector_eventr{� _selectorr Z EVENT_READ�join)rr3r�rrr�__repr__Es   z_UnixReadPipeTransport.__repr__cCs�ytj|j|j�}WnLttfk r6Yn�tk rj}z|j|d�WYdd}~Xn�X|r�|jj |�nj|j j �r�t j d|�nd|_|j j|j�|j j|jj�|j j|jd�dS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rs�readr}�max_size�BlockingIOError�InterruptedErrorr/� _fatal_errorr�Z data_receivedr{� get_debugrr3r�� remove_readerr�Z eof_received�_call_connection_lost)rr&r9rrrr�Xs# z"_UnixReadPipeTransport._read_readycCs|jj|j�dS)N)r{r�r})rrrr� pause_readingjsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|j�dS)N)r{r�r}r�)rrrr�resume_readingmsz%_UnixReadPipeTransport.resume_readingcCs|jS)N)r�)rrrr� is_closingpsz!_UnixReadPipeTransport.is_closingcCs|js|jd�ndS)N)r��_close)rrrrr!ss z_UnixReadPipeTransport.closecCs7|jdk r3tjd|t�|jj�ndS)Nzunclosed transport %r)r|�warnings�warn�ResourceWarningr!)rrrr�__del__{sz_UnixReadPipeTransport.__del__zFatal error on pipe transportcCs�t|t�rO|jtjkrO|jj�r~tjd||dd�q~n/|jji|d6|d6|d6|j d6�|j |�dS)Nz%r: %s�exc_infoT�message� exceptionrgrF) rAr/r4ZEIOr{r�r�debug�call_exception_handlerr�r�)rr9r�rrrr��s! z#_UnixReadPipeTransport._fatal_errorcCs6d|_|jj|j�|jj|j|�dS)NT)r�r{r�r}r�r�)rr9rrrr��s z_UnixReadPipeTransport._closec CsDz|jj|�Wd|jj�d|_d|_d|_XdS)N)r��connection_lostr|r!r{)rr9rrrr��s    z,_UnixReadPipeTransport._call_connection_losti)rnrorpr�rr�r�r�r�r�r!r�PY34r�r�r�r�rr)rrrD*s         rDcs�eZdZdd�fdd�Zdd�Zdd�Zdd �Zd d �Zd d �Zdd�Z dd�Z dd�Z dd�Z e jr�dd�Zndd�Zddd�Zddd�Zdd �Z�S)!rJNcsCt�j||�||jd<||_|j�|_tj|j�j}t j |�}|p}t j |�p}t j |�s�t d��nt|j�||_g|_d|_d|_|jj|jj|�|s�tjjd� r|jj|jj|j|j�n|dk r?|jjtj|d�ndS)NrEz?Pipe transport is only for pipes, sockets and character devicesrF�aix)rrrzr|r-r}rsr~rr�r�r�r�r.rur��_buffer� _conn_lostr�r{r�r��sys�platform� startswithr�r�r r�)rrLrErFrGrHr�Z is_socket)rrrr�s,        z _UnixWritePipeTransport.__init__cCs�|jjg}|jdkr.|jd�n|jrG|jd�n|jd|j�|jdk r�tj|jj |jt j �}|r�|jd�n |jd�|j �}|jd|�n |jd�ddj |�S) Nr�r�zfd=%sr�r�z bufsize=%sz<%s>r�)rrnr|r�r�r}r r�r{r�r Z EVENT_WRITE�get_write_buffer_sizer�)rr3r�rVrrrr��s"     z _UnixWritePipeTransport.__repr__cCstdd�|jD��S)Ncss|]}t|�VqdS)N)�len)�.0r&rrr� <genexpr>�sz@_UnixWritePipeTransport.get_write_buffer_size.<locals>.<genexpr>)�sumr�)rrrrr��sz-_UnixWritePipeTransport.get_write_buffer_sizecCsL|jj�r"tjd|�n|jr>|jt��n |j�dS)Nz%r was closed by peer)r{r�rr3r�r��BrokenPipeError)rrrrr��s  z#_UnixWritePipeTransport._read_readycCs�t|tttf�s*tt|���t|t�rHt|�}n|sRdS|jsd|jr�|jtj kr�t j d�n|jd7_dS|j styt j|j|�}Wnettfk r�d}YnHtk r"}z(|jd7_|j|d�dSWYdd}~XnX|t|�kr9dS|dkrX||d�}n|jj|j|j�n|j j|�|j�dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rA�bytes� bytearray� memoryviewra�reprr�r�rZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr�warningr�rs�writer}r�r�rQr�r�r{Z add_writer� _write_readyr�Z_maybe_pause_protocol)rr&�nr9rrrr��s4*   z_UnixWritePipeTransport.writecCsgdj|j�}|s$td��|jj�ytj|j|�}Wn~ttfk rt|jj |�Yn�t k r�}z7|j d7_ |j j |j�|j|d�WYdd}~Xn�X|t|�kr4|j j |j�|j�|j r0|jr0|j j|j�|jd�ndS|dkrS||d�}n|jj |�dS)N�zData should not be emptyrz#Fatal write error on pipe transportr)r�r�ra�clearrsr�r}r�r�r�rQr�r{� remove_writerr�r�Z_maybe_resume_protocolr�r�r�)rr&r�r9rrrr�s* #  z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr� can_write_eof sz%_UnixWritePipeTransport.can_write_eofcCs^|jr dS|jst�d|_|jsZ|jj|j�|jj|jd�ndS)NT) r�r|rar�r{r�r}r�r�)rrrr� write_eof#s   z!_UnixWritePipeTransport.write_eofcCs|jS)N)r�)rrrrr�,sz"_UnixWritePipeTransport.is_closingcCs*|jdk r&|j r&|j�ndS)N)r|r�r�)rrrrr!/sz_UnixWritePipeTransport.closecCs7|jdk r3tjd|t�|jj�ndS)Nzunclosed transport %r)r|r�r�r�r!)rrrrr�8sz_UnixWritePipeTransport.__del__cCs|jd�dS)N)r�)rrrr�abort=sz_UnixWritePipeTransport.abortzFatal error on pipe transportcCs�t|ttf�rC|jj�rrtjd||dd�qrn/|jji|d6|d6|d6|jd6�|j |�dS)Nz%r: %sr�Tr�r�rgrF) rAr��ConnectionResetErrorr{r�rr�r�r�r�)rr9r�rrrr�@s z$_UnixWritePipeTransport._fatal_errorcCsbd|_|jr(|jj|j�n|jj�|jj|j�|jj|j|�dS)NT) r�r�r{r�r}r�r�r�r�)rr9rrrr�Ns    z_UnixWritePipeTransport._closec CsDz|jj|�Wd|jj�d|_d|_d|_XdS)N)r�r�r|r!r{)rr9rrrr�Vs    z-_UnixWritePipeTransport._call_connection_lost)rnrorprr�r�r�r�r�r�r�r�r!rr�r�r�r�r�r�rr)rrrJ�s !   !      rJ�set_inheritablecCsittdd�}tj|tj�}|sJtj|tj||B�ntj|tj||@�dS)NZ FD_CLOEXECr)�getattrrvZF_GETFDZF_SETFD)rtZ inheritableZ cloexec_flag�oldrrr�_set_inheritablefs r�c@seZdZdd�ZdS)rNc Ks�d}|tjkr@|jj�\}}t|j�d�ntj|d|d|d|d|ddd||�|_|dk r�|j�t |j �dd |�|j_ ndS) NFrRrSrTrUZuniversal_newlinesrV�wb� buffering) � subprocess�PIPEr{r r�r-�Popen�_procr!�open�detachrS) rr8rRrSrTrUrVrWZstdin_wrrr�_startrs  z_UnixSubprocessTransport._startN)rnrorpr�rrrrrNps rNc@s^eZdZdZdd�Zdd�Zdd�Zdd �Zd d �Zd d �Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs t��dS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)�NotImplementedError)rr\r7r8rrrrO�s z&AbstractChildWatcher.add_child_handlercCs t��dS)z�Removes the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r�)rr\rrr�remove_child_handler�sz)AbstractChildWatcher.remove_child_handlercCs t��dS)z�Attach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r�)rrLrrr� attach_loop�sz AbstractChildWatcher.attach_loopcCs t��dS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r�)rrrrr!�szAbstractChildWatcher.closecCs t��dS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r�)rrrr� __enter__�szAbstractChildWatcher.__enter__cCs t��dS)zExit the watcher's contextN)r�)r�a�b�crrr�__exit__�szAbstractChildWatcher.__exit__N) rnrorprqrOr�r�r!r�r�rrrrr�s    c@sdeZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dS)�BaseChildWatchercCs d|_dS)N)r{)rrrrr�szBaseChildWatcher.__init__cCs|jd�dS)N)r�)rrrrr!�szBaseChildWatcher.closecCs t��dS)N)r�)r� expected_pidrrr� _do_waitpid�szBaseChildWatcher._do_waitpidcCs t��dS)N)r�)rrrr�_do_waitpid_all�sz BaseChildWatcher._do_waitpid_allcCs�|dks$t|tj�s$t�|jdk rI|jjtj�n||_|dk r�|jtj|j �|j �ndS)N) rArZAbstractEventLooprar{r#r+�SIGCHLDr;� _sig_chldr�)rrLrrrr��s$  zBaseChildWatcher.attach_loopcCsXy|j�WnCtk rS}z#|jjidd6|d6�WYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handlerr�r�)r�rQr{r�)rr9rrrr��s  zBaseChildWatcher._sig_chldcCsAtj|�rtj|� Stj|�r9tj|�S|SdS)N)rs� WIFSIGNALED�WTERMSIG� WIFEXITED� WEXITSTATUS)r�statusrrr�_compute_returncode�s  z$BaseChildWatcher._compute_returncodeN) rnrorprr!r�r�r�r�r�rrrrr��s       r�cs�eZdZdZ�fdd�Z�fdd�Zdd�Zdd �Zd d �Zd d �Z dd�Z dd�Z �S)rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cst�j�i|_dS)N)rr� _callbacks)r)rrrrs zSafeChildWatcher.__init__cs|jj�t�j�dS)N)r�r�rr!)r)rrrr!s zSafeChildWatcher.closecCs|S)Nr)rrrrr�szSafeChildWatcher.__enter__cCsdS)Nr)rr�r�r�rrrr�szSafeChildWatcher.__exit__cGs$||f|j|<|j|�dS)N)r�r�)rr\r7r8rrrrOsz"SafeChildWatcher.add_child_handlerc Cs/y|j|=dSWntk r*dSYnXdS)NTF)r�r=)rr\rrrr�$s   z%SafeChildWatcher.remove_child_handlercCs+x$t|j�D]}|j|�qWdS)N)r"r�r�)rr\rrrr�+sz SafeChildWatcher._do_waitpid_allcCs|dkst�ytj|tj�\}}Wn.tk ra|}d}tjd|�YnEX|dkrrdS|j|�}|jj �r�tj d||�ny|j j |�\}}Wn:t k r�|jj �r�tjd|dd�nYnX||||�dS)Nr�z8Unknown child process pid %d, will report returncode 255z$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rr�T)rars�waitpid�WNOHANG�ChildProcessErrorrr�r�r{r�r�r��popr=)rr�r\r�r]r7r8rrrr�0s,       zSafeChildWatcher._do_waitpid) rnrorprqrr!r�r�rOr�r�r�rr)rrrs      csveZdZdZ�fdd�Z�fdd�Zdd�Zdd �Zd d �Zd d �Z dd�Z �S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs;t�j�i|_tj�|_i|_d|_dS)Nr)rrr�� threadingZLock�_lock�_zombies�_forks)r)rrrr]s    zFastChildWatcher.__init__cs+|jj�|jj�t�j�dS)N)r�r�r�rr!)r)rrrr!ds  zFastChildWatcher.closec Cs'|j�|jd7_|SWdQXdS)Nr)r�r�)rrrrr�is zFastChildWatcher.__enter__c Csf|j�G|jd8_|js,|j r0dSt|j�}|jj�WdQXtjd|�dS)Nrz5Caught subprocesses termination from unknown pids: %s)r�r�r�r1r�rr�)rr�r�r�Zcollateral_victimsrrrr�os zFastChildWatcher.__exit__cGs{|jstd��|j�Gy|jj|�}Wn)tk r`||f|j|<dSYnXWdQX||||�dS)NzMust use the context manager)r�rar�r�r�r=r�)rr\r7r8r]rrrrO}s  z"FastChildWatcher.add_child_handlerc Cs/y|j|=dSWntk r*dSYnXdS)NTF)r�r=)rr\rrrr��s   z%FastChildWatcher.remove_child_handlercCsAx:ytjdtj�\}}Wntk r:dSYn X|dkrKdS|j|�}|j��y|jj|�\}}WnYtk r�|j r�||j |<|j j �r�t jd||�nwnd}Yn&X|j j �rt jd||�nWdQX|dkr)t jd||�q||||�qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr()rsr�r�r�r�r�r�r�r=r�r�r{r�rr�r�)rr\r�r]r7r8rrrr��s6             z FastChildWatcher._do_waitpid_all) rnrorprqrr!r�r�rOr�r�rr)rrrSs    csdeZdZdZeZ�fdd�Zdd�Z�fdd�Zdd �Z d d �Z �S) �_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cst�j�d|_dS)N)rr�_watcher)r)rrrr�s z$_UnixDefaultEventLoopPolicy.__init__c Csctj�T|jdkrYt�|_ttj�tj�rY|jj|j j �qYnWdQXdS)N) rr�r�rrAr��current_thread� _MainThreadr��_localr{)rrrr� _init_watcher�s     z)_UnixDefaultEventLoopPolicy._init_watchercsNt�j|�|jdk rJttj�tj�rJ|jj|�ndS)z�Set the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)r�set_event_loopr�rAr�r�r�r�)rrL)rrrr��sz*_UnixDefaultEventLoopPolicy.set_event_loopcCs#|jdkr|j�n|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)r�r�)rrrrrM�s z-_UnixDefaultEventLoopPolicy.get_child_watchercCsM|dks!t|t�s!t�|jdk r@|jj�n||_dS)z$Set the watcher for child processes.N)rArrar�r!)rrXrrr�set_child_watcher�s!z-_UnixDefaultEventLoopPolicy.set_child_watcher) rnrorprqrZ _loop_factoryrr�r�rMr�rr)rrr��s   r�)2rqr4rsr+rr�r�r�r�r��rrrrrrr r r r r �logr�__all__r�� ImportErrorrZBaseSelectorEventLoopr�hasattrrurvZ ReadTransportrDZ_FlowControlMixinZWriteTransportrJr�r�ZBaseSubprocessTransportrNrr�rrZBaseDefaultEventLoopPolicyr�rrrrrr�<module>s^           �  s �   F6Ni2