OwlCyberSecurity - MANAGER
Edit File: base_events.cpython-35.opt-1.pyc
��Yf����������������� ���@���s���d��Z��d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l �Z �d�d�l �Z �d�d�l�Z�d�d�l�Z�d�d�l �Z �d�d�l�Z�d�d�l�Z�d�d�l�Z�d�d�l�m�Z�d�d�l�m�Z�d�d�l�m�Z�d�d�l�m�Z�d�d�l�m�Z�d�d �l�m�Z�d�d �l�m�Z�d�g�Z�d�Z�d �Z�e�e�e�f�Z �d�d����Z!�d�d����Z"�d�d����Z#�d�d����Z$�d�d����Z%�d�d����Z&�d�d�d�e �j'�d�d�d�d�d�d���Z(�d �d!����Z)�Gd"�d#����d#�e�j*���Z+�Gd$�d����d�e�j,���Z-�d�S)%a���Base implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. �����N����)�compat)� coroutines)�events)�futures)�tasks)� coroutine)�logger� BaseEventLoop�d���g�������?c�������������C���sH���|��j��}�t�j�|���r:�t�|�j�t�j���r:�t�|�j���St�|����Sd��S)N) Z _callback�inspectZismethod� isinstance�__self__r����Task�repr�str)�handle�cb��r����8/opt/alt/python35/lib64/python3.5/asyncio/base_events.py�_format_handle:���s���� $ r���c�������������C���s4���|��t��j�k�r�d�S|��t��j�k�r&�d�St�|����Sd��S)Nz<pipe>z<stdout>)� subprocess�PIPE�STDOUTr���)�fdr���r���r����_format_pipeC���s ����r���c�������������C���s`���t��t�d���s�t�d�����n>�y�|��j�t�j�t�j�d���Wn�t�k �r[�t�d�����Yn�Xd��S)N�SO_REUSEPORTz)reuse_port not supported by socket moduler���zTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)�hasattr�socket� ValueError� setsockopt� SOL_SOCKETr����OSError)�sockr���r���r����_set_reuseportL���s���� r$���c�������������C���s���|��j��t�j�@t�j�k�S)N)�typer����SOCK_STREAM)r#���r���r���r����_is_stream_socketW���s����r'���c�������������C���s���|��j��t�j�@t�j�k�S)N)r%���r���� SOCK_DGRAM)r#���r���r���r����_is_dgram_socket^���s����r)���c�������������C���s���t��t�d���s�d��S|�d�t�j�t�j�h�k�s:�|��d��k�r>�d��S|�t�j�k�rY�t�j�}�n�|�t�j�k�rt�t�j�}�n�d��S|�d��k�r��d�}�nw�t�|�t���r��|�d�k�r��d�}�nS�t�|�t���r��|�d�k�r��d�}�n/�y�t �|���}�Wn�t �t�f�k �rd��SYn�X|�t�j�k�rAt�j �g�}�t��t�d���rJ|�j�t�j���n �|�g�}�t�|��t���rh|��j�d���}��d�|��k�rxd��SxP�|�D]H�}�y-�t�j�|�|����|�|�|�d�|��|�f�f�SWqt�k �r�YqXqWd��S)N� inet_ptonr�����������AF_INET6Zidna�%)r���r���ZIPPROTO_TCPZIPPROTO_UDPr&���r(���r ����bytesr����int� TypeErrorr���� AF_UNSPECZAF_INET�appendr-����decoder*���r"���)�host�port�familyr%����protoZafs�afr���r���r����_ipaddr_infoe���sH���� r:���r7���r%���r8����flagsc������ ������C���s����|��d��d���\�}�}�t��|�|�|�|�|���}�|�d��k �rZ�|�j����} �| �j�|�g���| �S|�j�|�|�d�|�d�|�d�|�d�|��Sd��S)N����r7���r%���r8���r;���)r:���� create_future� set_result�getaddrinfo) �addressr7���r%���r8���r;����loopr5���r6����info�futr���r���r����_ensure_resolved����s����rD���c�������������C���s=���|��j��}�t�|�t���r,�t�|�t���r,�d��S|��j�j����d��S)N)Z _exceptionr ���� BaseException� Exception�_loop�stop)rC����excr���r���r����_run_until_complete_cb����s ���� rJ���c���������������@���sj���e��Z�d��Z�d�d����Z�d�d����Z�d�d����Z�d�d����Z�d �d ����Z�d�d����Z�e �d �d������Z �d�S)�Serverc�������������C���s(���|�|��_��|�|��_�d�|��_�g��|��_�d��S)Nr���)rG����sockets� _active_count�_waiters)�selfrA���rL���r���r���r����__init__����s���� zServer.__init__c�������������C���s���d�|��j��j�|��j�f�S)Nz<%s sockets=%r>)� __class__�__name__rL���)rO���r���r���r����__repr__����s����zServer.__repr__c�������������C���s���|��j��d�7_��d��S)Nr���)rM���)rO���r���r���r����_attach����s����zServer._attachc�������������C���s;���|��j��d�8_��|��j��d�k�r7�|��j�d��k�r7�|��j����d��S)Nr���r���)rM���rL����_wakeup)rO���r���r���r����_detach����s����zServer._detachc�������������C���s`���|��j��}�|�d��k�r�d��Sd��|��_��x�|�D]�}�|��j�j�|���q)�W|��j�d�k�r\�|��j����d��S)Nr���)rL���rG���Z _stop_servingrM���rU���)rO���rL���r#���r���r���r����close����s���� zServer.closec�������������C���s@���|��j��}�d��|��_��x'�|�D]�}�|�j����s�|�j�|���q�Wd��S)N)rN����doner>���)rO����waiters�waiterr���r���r���rU�������s ���� zServer._wakeupc�������������c���sN���|��j��d��k�s�|��j�d��k�r"�d��S|��j�j����}�|��j�j�|���|�Ed��Hd��S)N)rL���rN���rG���r=���r3���)rO���rZ���r���r���r����wait_closed����s ����zServer.wait_closedN)rR���� __module__�__qualname__rP���rS���rT���rV���rW���rU���r���r[���r���r���r���r���rK�������s��� rK���c���������������@���s���e��Z�d��Z�d�d����Z�d�d����Z�d�d����Z�d�d����Z�d �d ����Z�d�d����Z�d �d�d �d�d �d�d��Z �d �d�d�d�d �d�d �d�d �d�d��Z �d �d �d �d�d���Z�d �d �d�d���Z�d �d �d�d���Z �e�d �d�d�����Z�d�d ����Z�d!�d"����Z�d#�d$����Z�d%�d&����Z�d'�d(����Z�e�d)�d*������Z�d+�d,����Z�d-�d.����Z�d/�d0����Z�d1�d2����Z�d3�d4����Z�e�j�r�d5�d6����Z�d7�d8����Z�d9�d:����Z�d;�d<����Z �d=�d>����Z!�d?�d@����Z"�dA�dB����Z#�dC�dD����Z$�dE�dF����Z%�dG�dH����Z&�dI�dJ����Z'�dK�dL����Z(�dM�dN����Z)�dO�dP�dQ�dP�dR�dP�dS�dP�dT�dU���Z*�dP�dV�dW���Z+�e�d �d �dX�d �dO�dP�dR�dP�dS�dP�dY�d �dZ�d �d�d �d[�d\����Z,�e�d�d]�d^�����Z-�e�d �d �dO�dP�dR�dP�dS�dP�d_�d �d`�d �da�d �dY�d �db�dc����Z.�e�dd�de������Z/�e�d �d �dO�e0�j1�dS�e0�j2�dY�d �df�dg�dX�d �d_�d �d`�d �dh�di����Z3�e�dX�d �dj�dk�����Z4�e�dl�dm������Z5�e�dn�do������Z6�dp�dq����Z7�e�dr�e8�j9�ds�e8�j9�dt�e8�j9�du�d�dv�dw�dx�dP�dy�dz�����Z:�e�dr�e8�j9�ds�e8�j9�dt�e8�j9�du�d�dv�d�dx�dP�d{�d|�����Z;�d}�d~����Z<�d�d�����Z=�d��d�����Z>�d��d�����Z?�d��d�����Z@�d��d�����ZA�d��d�����ZB�d��d�����ZC�d��d�����ZD�d��d�����ZE�d��d�����ZF�d �S)�r ���c�������������C���s����d�|��_��d�|��_�d�|��_�t�j����|��_�g��|��_�d��|��_�d�|��_�d��|��_ �t �j�d���j�|��_ �d��|��_�|��j�t�j�j�o��t�t�j�j�d�������d�|��_�d��|��_�d��|��_�d�|��_�t�t�d���r��t�j����|��_�n �d��|��_�d�|��_�d��S)Nr���F� monotonicZPYTHONASYNCIODEBUGg�������?�get_asyncgen_hooks) �_timer_cancelled_count�_closed� _stopping�collections�deque�_ready� _scheduled�_default_executorZ _internal_fds� _thread_id�timeZget_clock_infoZ resolution�_clock_resolution�_exception_handler� set_debug�sysr;����ignore_environment�bool�os�environ�get�slow_callback_duration�_current_handle� _task_factory�_coroutine_wrapper_setr����weakref�WeakSet� _asyncgens�_asyncgens_shutdown_called)rO���r���r���r���rP�������s(���� zBaseEventLoop.__init__c�������������C���s,���d�|��j��j�|��j����|��j����|��j����f�S)Nz"<%s running=%s closed=%s debug=%s>)rQ���rR���� is_running� is_closed� get_debug)rO���r���r���r���rS�����s����zBaseEventLoop.__repr__c�������������C���s���t��j�d�|����S)z,Create a Future object attached to the loop.rA���)r���ZFuture)rO���r���r���r���r=�����s����zBaseEventLoop.create_futurec�������������C���sZ���|��j�����|��j�d�k�rD�t�j�|�d�|���}�|�j�rV�|�j�d�=n�|��j�|��|���}�|�S)zDSchedule a coroutine object. Return a task object. NrA���r������)� _check_closedru���r���r����_source_traceback)rO����coroZtaskr���r���r����create_task��s���� zBaseEventLoop.create_taskc�������������C���s2���|�d�k �r%�t��|���r%�t�d�����|�|��_�d�S)aw��Set a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)�callabler1���ru���)rO����factoryr���r���r����set_task_factory#��s���� zBaseEventLoop.set_task_factoryc�������������C���s���|��j��S)z<Return a task factory, or None if the default one is in use.)ru���)rO���r���r���r����get_task_factory1��s����zBaseEventLoop.get_task_factoryN�extra�serverc������������C���s ���t����d�S)zCreate socket transport.N)�NotImplementedError)rO���r#����protocolrZ���r����r����r���r���r����_make_socket_transport5��s����z$BaseEventLoop._make_socket_transport�server_sideF�server_hostnamec������ ������C���s ���t����d�S)zCreate SSL transport.N)r����) rO���Zrawsockr����� sslcontextrZ���r����r����r����r����r���r���r����_make_ssl_transport:��s����z!BaseEventLoop._make_ssl_transportc�������������C���s ���t����d�S)zCreate datagram transport.N)r����)rO���r#���r����r@���rZ���r����r���r���r����_make_datagram_transport@��s����z&BaseEventLoop._make_datagram_transportc�������������C���s ���t����d�S)zCreate read pipe transport.N)r����)rO����piper����rZ���r����r���r���r����_make_read_pipe_transportE��s����z'BaseEventLoop._make_read_pipe_transportc�������������C���s ���t����d�S)zCreate write pipe transport.N)r����)rO���r����r����rZ���r����r���r���r����_make_write_pipe_transportJ��s����z(BaseEventLoop._make_write_pipe_transportc ������� ������K���s ���t����d�S)zCreate subprocess transport.N)r����) rO���r�����args�shell�stdin�stdout�stderr�bufsizer�����kwargsr���r���r����_make_subprocess_transportO��s����z(BaseEventLoop._make_subprocess_transportc�������������C���s ���t����d�S)z�Write a byte to self-pipe, to wake up the event loop. This may be called from a different thread. The subclass is responsible for implementing the self-pipe. N)r����)rO���r���r���r����_write_to_selfV��s����zBaseEventLoop._write_to_selfc�������������C���s ���t����d�S)zProcess selector events.N)r����)rO���� event_listr���r���r����_process_events_��s����zBaseEventLoop._process_eventsc�������������C���s���|��j��r�t�d�����d��S)NzEvent loop is closed)ra����RuntimeError)rO���r���r���r���r���c��s���� zBaseEventLoop._check_closedc�������������C���s=���|��j��j�|���|��j����s9�|��j�|�j������|��j����d��S)N)ry����discardr|���r�����acloser����)rO����agenr���r���r����_asyncgen_finalizer_hookg��s����z&BaseEventLoop._asyncgen_finalizer_hookc�������������C���s<���|��j��r(�t�j�d�j�|���t�d�|���|��j�j�|���d��S)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call�source)rz����warnings�warn�format�ResourceWarningry����add)rO���r����r���r���r����_asyncgen_firstiter_hooko��s���� z&BaseEventLoop._asyncgen_firstiter_hookc�������������c���s����d�|��_��|��j�d�k�s(�t�|��j���r,�d�St�|��j���}�|��j�j����t�j�d�d����|�D��d�d�d�|����}�|�Ed�H}�xT�t�|�|���D]C�\�}�}�t�|�t ���r��|��j �d�d�j�|���d �|�d �|�i���q��Wd�S)z,Shutdown all active asynchronous generators.TNc�������������S���s���g��|��]�}�|�j�������q�Sr���)r����)�.0Zagr���r���r���� <listcomp>���s��� �z4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>Zreturn_exceptionsrA����messagez?an error occurred during closing of asynchronous generator {!r}� exceptionZasyncgen)rz���ry����len�list�clearr����gather�zipr ���rF����call_exception_handlerr����)rO���Z closing_agensZ shutdown_coroZresults�resultr����r���r���r����shutdown_asyncgensx��s"���� z BaseEventLoop.shutdown_asyncgensc�������������C���s��|��j�����|��j����r"�t�d�����t�j����d�k �r@�t�d�����|��j�|��j���t�j����|��_ �|��j �d�k �r��t�j����}�t�j �d�|��j�d�|��j���z,�t�j�|����x�|��j����|��j�r��Pq��WWd�d�|��_�d�|��_ �t�j�d���|��j�d���|��j �d�k �r t�j �|����Xd�S)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is runningZ firstiterZ finalizerF)r���r{���r����r���Z_get_running_loop�_set_coroutine_wrapper�_debug� threading� get_identrh���ry���rm���r_���Zset_asyncgen_hooksr����r����Z_set_running_loop� _run_oncerb���)rO���Zold_agen_hooksr���r���r����run_forever���s0���� zBaseEventLoop.run_foreverc�������������C���s����|��j�����t�j�|���}�t�j�|�d�|���}�|�r>�d�|�_�|�j�t���zI�y�|��j����Wn4�|�r��|�j ����r��|�j ����r��|�j�������Yn�XWd�|�j�t���X|�j ����s��t �d�����|�j����S)a\��Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. rA���FNz+Event loop stopped before Future completed.)r���r���Zisfuturer���Z ensure_futureZ_log_destroy_pendingZadd_done_callbackrJ���r����rX���Z cancelledr����Zremove_done_callbackr����r����)rO���ZfutureZnew_taskr���r���r����run_until_complete���s ���� z BaseEventLoop.run_until_completec�������������C���s ���d�|��_��d�S)z�Stop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rb���)rO���r���r���r���rH������s����zBaseEventLoop.stopc�������������C���s����|��j�����r�t�d�����|��j�r%�d�S|��j�r>�t�j�d�|����d�|��_�|��j�j����|��j�j����|��j �}�|�d�k �r��d�|��_ �|�j �d�d���d�S)z�Close the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rT�waitF)r{���r����ra���r����r ����debugre���r����rf���rg���Zshutdown)rO����executorr���r���r���rW������s���� zBaseEventLoop.closec�������������C���s���|��j��S)z*Returns True if the event loop was closed.)ra���)rO���r���r���r���r|������s����zBaseEventLoop.is_closedc�������������C���s:���|��j�����s6�t�j�d�|��t���|��j����s6�|��j����d��S)Nzunclosed event loop %r)r|���r����r����r����r{���rW���)rO���r���r���r����__del__���s����zBaseEventLoop.__del__c�������������C���s ���|��j��d�k �S)z*Returns True if the event loop is running.N)rh���)rO���r���r���r���r{�����s����zBaseEventLoop.is_runningc�������������C���s ���t��j����S)z�Return the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )ri���r^���)rO���r���r���r���ri�����s����zBaseEventLoop.timec�������������G���s6���|��j��|��j����|�|�|���}�|�j�r2�|�j�d�=|�S)a8��Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. r���r~���)�call_atri���r����)rO���Zdelay�callbackr�����timerr���r���r���� call_later��s���� zBaseEventLoop.call_laterc�������������G���sx���|��j�����|��j�r-�|��j����|��j�|�d���t�j�|�|�|�|����}�|�j�rX�|�j�d�=t�j�|��j �|���d�|�_ �|�S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. r����r���Tr~���) r���r����� _check_thread�_check_callbackr���ZTimerHandler�����heapq�heappushrf���)rO����whenr����r����r����r���r���r���r����#��s���� zBaseEventLoop.call_atc�������������G���sV���|��j�����|��j�r-�|��j����|��j�|�d���|��j�|�|���}�|�j�rR�|�j�d�=|�S)aT��Arrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. � call_soonr���r~���)r���r����r����r����� _call_soonr����)rO���r����r����r���r���r���r���r����3��s���� zBaseEventLoop.call_soonc�������������C���s[���t��j�|���s�t��j�|���r3�t�d�j�|�������t�|���sW�t�d�j�|�|�������d��S)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})r���ZiscoroutineZiscoroutinefunctionr1���r����r����)rO���r�����methodr���r���r���r����F��s����zBaseEventLoop._check_callbackc�������������C���s<���t��j�|�|�|����}�|�j�r(�|�j�d�=|��j�j�|���|�S)Nr���r~���)r���ZHandler����re���r3���)rO���r����r����r���r���r���r���r����Q��s ���� zBaseEventLoop._call_soonc�������������C���s>���|��j��d�k�r�d�St�j����}�|�|��j��k�r:�t�d�����d�S)ao��Check that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rh���r����r����r����)rO���Z thread_idr���r���r���r����X��s���� zBaseEventLoop._check_threadc�������������G���sV���|��j�����|��j�r#�|��j�|�d���|��j�|�|���}�|�j�rH�|�j�d�=|��j����|�S)z"Like call_soon(), but thread-safe.�call_soon_threadsafer���r~���)r���r����r����r����r����r����)rO���r����r����r���r���r���r���r����i��s���� z"BaseEventLoop.call_soon_threadsafec�������������G���s{���|��j�����|��j�r#�|��j�|�d���|�d��k�r\�|��j�}�|�d��k�r\�t�j�j����}�|�|��_�t�j�|�j�|�|���d�|���S)N�run_in_executorrA���) r���r����r����rg���� concurrentr���ZThreadPoolExecutorZwrap_futureZsubmit)rO���r�����funcr����r���r���r���r����t��s���� zBaseEventLoop.run_in_executorc�������������C���s ���|�|��_��d��S)N)rg���)rO���r����r���r���r����set_default_executor��s����z"BaseEventLoop.set_default_executorc�������������C���s��d�|�|�f�g�}�|�r*�|�j��d�|���|�rA�|�j��d�|���|�rX�|�j��d�|���|�ro�|�j��d�|���d�j�|���}�t�j�d�|���|��j����}�t�j�|�|�|�|�|�|���} �|��j����|�} �d�|�| �d �| �f�}�| �|��j�k�r��t�j�|���n �t�j�|���| �S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg�����@�@) r3����joinr ���r����ri���r���r?���rs���rB���)rO���r5���r6���r7���r%���r8���r;����msg�t0Zaddrinfo�dtr���r���r����_getaddrinfo_debug���s(���� z BaseEventLoop._getaddrinfo_debugr7���r���r%���r8���r;���c��������� ���C���sW���|��j��r.�|��j�d��|��j�|�|�|�|�|�|���S|��j�d��t�j�|�|�|�|�|�|���Sd��S)N)r����r����r����r���r?���)rO���r5���r6���r7���r%���r8���r;���r���r���r���r?������s ���� zBaseEventLoop.getaddrinfoc�������������C���s���|��j��d��t�j�|�|���S)N)r����r����getnameinfo)rO���Zsockaddrr;���r���r���r���r�������s����zBaseEventLoop.getnameinfo�sslr#���� local_addrc������������#���s#��| �d�k �r�|�r�t��d�����| �d�k�rI�|�rI�|�sC�t��d�����|�} �|�d�k �sa�|�d�k �r�|�d�k �ry�t��d�����t�|�|�f�d�|�d�t�j�d�|�d�|�d �|���}�|�g�}�| �d�k �r��t�| �d�|�d�t�j�d�|�d�|�d �|���} �|�j�| ���n�d�} �t�j�|�d �|���Ed�H|�j����}�|�s:t�d �����| �d�k �rd| �j����}�|�sdt�d �����g��}�xU|�D]�\�}�}�}�}�}�y t�j�d�|�d�|�d�|���}�|�j �d���| �d�k �rax��|�D]��\�}�}�}�}�}�y�|�j �|���PWq�t�k �rI}�z9�t�|�j�d�j�|�|�j �j��������}�|�j�|���WYd�d�}�~�Xq�Xq�W|�j����d�}�wq|��j�r}t�j�d �|�|���|��j�|�|���Ed�HWnh�t�k �r�}�z(�|�d�k �r�|�j����|�j�|���WYd�d�}�~�Xqq|�d�k �r�|�j�������YqqXPqqWt�|���d�k�r"|�d���q�t�|�d������t����f�d�d����|�D����r[|�d���t�d�j�d�j�d�d����|�D����������n9�|�d�k�r�t��d�����t�|���s�t��d�j�|�������|��j�|�|�|�| ���Ed�H\�}�}�|��j�r|�j�d���}�t�j�d�|�|�|�|�|���|�|�f�S)a���Connect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same timer7���r%���r8���r;���rA���z!getaddrinfo() returned empty listFz2error while attempting to bind on address {!r}: {}zconnect %r to %rr���r���c�������������3���s!���|��]�}�t��|������k�Vq�d��S)N)r���)r����rI���)�modelr���r���� <genexpr>��s����z2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, c�������������s���s���|��]�}�t��|���Vq�d��S)N)r���)r����rI���r���r���r���r������s����z5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r���z%r connected to %s:%r: (%r, %r))r���rD���r���r&���r3���r���r����r����r"����setblocking�bind�errnor�����strerror�lowerrW���r����r ���r�����sock_connectr����r����allr����r'����_create_connection_transport�get_extra_info)rO����protocol_factoryr5���r6���r����r7���r8���r;���r#���r����r�����f1�fs�f2�infosZladdr_infos� exceptionsr%���Zcnamer@����_ZladdrrI���� transportr����r���)r����r����create_connection���s����� $ % zBaseEventLoop.create_connectionc������� ��� ���c���s����|�j��d���|����}�|��j����}�|�rj�t�|�t���r=�d��n�|�}�|��j�|�|�|�|�d�|�d�|��} �n�|��j�|�|�|���} �y �|�Ed��HWn�| �j�������Yn�X| �|�f�S)NFr����r����)r����r=���r ���ro���r����r����rW���) rO���r#���r����r����r����r����r����rZ���r����r����r���r���r���r����+��s���� z*BaseEventLoop._create_connection_transport� reuse_address� reuse_port�allow_broadcastc������������#���sT��| �d�k �r��t��| ���s-�t�d�j�| ����������s]���s]�|�s]�|�s]�|�s]�|�s]�|�s]�| �r��t�d����d���d�|�d�|�d�|�d�|�d �|�d �| ���}�d�j�d�d ����|�j����D����}�t�d�j�|�������| �j�d���d�} �n����p����s|�d�k�rt�d�����|�|�f�d�f�f�}�nt�j����}�x��d����f�d���f�f�D]��\�}�}�|�d�k �rDt �|�d�|�d�t �j�d�|�d�|�d�|���Ed�H}�|�s�t�d�����xS�|�D]K�\�}�}�}�}�}�|�|�f�}�|�|�k�r�d�d�g�|�|�<|�|�|�|�<q�WqDW�����f�d�d����|�j����D��}�|�s.t�d�����g��}�|�d�k�r^t �j�d�k�o[t�j�d�k�}�xV|�D]D\�\�}�}�\�}�}�d�} �d�} �y��t �j �d�|�d�t �j�d�|���} �|�r�| �j�t �j�t �j�d���|�r�t�| ���| �r�| �j�t �j�t �j�d���| �j�d������r| �j�|�����r<|��j�| �|���Ed�H|�} �Wnh�t�k �r�}�z(�| �d�k �rh| �j����|�j�|���WYd�d�}�~�Xqe| �d�k �r�| �j�������YqeXPqeW|�d���|����}�|��j����}�|��j�| �|�| �|���}�|��j�r%���rt�j�d������|�|���n�t�j�d���|�|���y �|�Ed�HWn�|�j�������Yn�X|�|�f�S)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r}r�����remote_addrr7���r8���r;���r����r����r����z, c�������������s���s-���|��]#�\�}�}�|�r�d��j��|�|���Vq�d�S)z{}={}N)r����)r�����k�vr���r���r���r����W��s����z9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zNsocket modifier keyword arguments can not be used when sock is specified. ({})Fr���zunexpected address familyr���r%���rA���z!getaddrinfo() returned empty listc����������������sN���g��|��]D�\�}�}����r(�|�d��d�k�p;���o;�|�d�d�k�s�|�|�f���q�S)r���Nr���r���)r�����keyZ addr_pair)r����r����r���r���r����x��s��� � z:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>zcan not get address information�posix�cygwinz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r)���r���r�����dictr�����itemsr����rc����OrderedDictrD���r���r(���r"���rp����namerm����platformr ���r!����SO_REUSEADDRr$���ZSO_BROADCASTr����r����rW���r3���r=���r����r����r ���rB���r����)rO���r����r����r����r7���r8���r;���r����r����r����r#���ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infos�idxZaddrr����Zfamr����Zpror@���r����r����Z local_addressZremote_addressrI���r����rZ���r����r���)r����r����r����create_datagram_endpointC��s����� %" z&BaseEventLoop.create_datagram_endpointc���������� ���c���sQ���t��|�|�f�d�|�d�t�j�d�|�d�|���Ed��H}�|�sM�t�d�j�|�������|�S)Nr7���r%���r;���rA���z%getaddrinfo({!r}) returned empty list)rD���r���r&���r"���r����)rO���r5���r6���r7���r;���r����r���r���r����_create_server_getaddrinfo���s���� z(BaseEventLoop._create_server_getaddrinfo�backlogr���c��������� ���#���sd��t��|�t���r�t�d�����|�d�k �s3���d�k �r�|�d�k �rK�t�d�����t�t�d�d���}�| �d�k�r��t�j�d�k�o��t�j �d�k�} �g��}�|�d�k�r��d�g�} �n4�t��|�t ���s��t��|�t�j���r��|�g�} �n�|�} ����������f�d �d ����| �D��}�t �j�|�d�����Ed�H}�t�t�j�j�|�����}�d�}�zWxJ|�D]B}�|�\�}�}�}�}�}�y�t�j�|�|�|���}�Wn=�t�j�k �r���j�r�t�j�d �|�|�|�d�d��w=Yn�X|�j�|���| �r�|�j�t�j�t�j�d���| �r�t�|���|�|�k�r!t�t�d���r!|�j�t�j�t�j�d���y�|�j�|���Wq=t �k �r~}�z*�t �|�j!�d�|�|�j"�j#����f�����WYd�d�}�~�Xq=Xq=Wd�}�Wd�|�s�x�|�D]�}�|�j$����q�WXnB�|�d�k�r�t�d�����t%�|���s�t�d�j&�|�������|�g�}�t'���|���}�xA�|�D]9�}�|�j(�|���|�j)�d�����j*�|�|�|�|�|���q W��j�r`t�j+�d�|���|�S)a1��Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNz8host/port and sock can not be specified at the same timer-���r���r����r����r,���c���������� ������s.���g��|��]$�}���j��|���d�����d������q�S)r7���r;���)r���)r����r5���)r7���r;���r6���rO���r���r���r�������s��� z/BaseEventLoop.create_server.<locals>.<listcomp>rA���Fz:create_server() failed to create socket.socket(%r, %r, %r)�exc_infoT�IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving),r ���ro���r1���r����getattrr���rp���r����rm���r����r���rc����Iterabler���r�����set� itertools�chain� from_iterable�errorr����r ����warningr3���r ���r!���r����r$���r���r��ZIPV6_V6ONLYr����r"���r����r����r����rW���r'���r����rK���Zlistenr����Z_start_servingrB���)rO���r����r5���r6���r7���r;���r#���r��r����r����r����r-���rL���Zhostsr����r����Z completed�resr9���Zsocktyper8���Z canonnameZsa�errr����r���)r7���r;���r6���rO���r���� create_server���s����� 0 zBaseEventLoop.create_serverc������������c���s����t��|���s!�t�d�j�|�������|��j�|�|�|�d�d�d��Ed�H\�}�}�|��j�rx�|�j�d���}�t�j�d�|�|�|���|�|�f�S)a��Handle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r,���r����TNr���z%r handled: (%r, %r))r'���r���r����r����r����r����r ���r����)rO���r����r#���r����r����r����r���r���r����connect_accepted_socket.��s���� # z%BaseEventLoop.connect_accepted_socketc�������������c���s~���|����}�|��j�����}�|��j�|�|�|���}�y �|�Ed��HWn�|�j�������Yn�X|��j�rt�t�j�d�|�j����|�|���|�|�f�S)Nz Read pipe %r connected: (%r, %r))r=���r����rW���r����r ���r�����fileno)rO���r����r����r����rZ���r����r���r���r����connect_read_pipeE��s���� zBaseEventLoop.connect_read_pipec�������������c���s~���|����}�|��j�����}�|��j�|�|�|���}�y �|�Ed��HWn�|�j�������Yn�X|��j�rt�t�j�d�|�j����|�|���|�|�f�S)Nz!Write pipe %r connected: (%r, %r))r=���r����rW���r����r ���r����r��)rO���r����r����r����rZ���r����r���r���r����connect_write_pipeV��s���� z BaseEventLoop.connect_write_pipec�������������C���s����|�g�}�|�d��k �r,�|�j��d�t�|�����|�d��k �ra�|�t�j�k�ra�|�j��d�t�|�����nF�|�d��k �r��|�j��d�t�|�����|�d��k �r��|�j��d�t�|�����t�j�d�j�|�����d��S)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s� )r3���r���r���r���r ���r����r����)rO���r����r����r����r����rB���r���r���r����_log_subprocessg��s���� zBaseEventLoop._log_subprocessr����r����r�����universal_newlinesr����Tr����c������ ��� ���k���s����t��|�t�t�f���s!�t�d�����|�r3�t�d�����|�sE�t�d�����|�d�k�r]�t�d�����|����} �|��j�r��d�|�}�|��j�|�|�|�|���|��j�| �|�d�|�|�|�|�| ���Ed��H}�|��j�r��t�j�d�|�|���|�| �f�S) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truer���zbufsize must be 0zrun shell command %rTz%s: %r) r ���r/���r���r���r����r��r����r ���rB���) rO���r�����cmdr����r����r����r��r����r����r����r����� debug_logr����r���r���r����subprocess_shellt��s"���� # zBaseEventLoop.subprocess_shellc��������� ���o���s ��|�r�t��d�����|�r$�t��d�����|�d�k�r<�t��d�����|�f�| �}�x<�|�D]4�}�t�|�t�t�f���sP�t�d�t�|���j�����qP�W|����} �|��j�r��d�|�}�|��j�|�|�|�|���|��j �| �|�d�|�|�|�|�| ���Ed��H}�|��j�r��t �j�d�|�|���|�| �f�S) Nz universal_newlines must be Falsezshell must be Falser���zbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r)r���r ���r���r/���r1���r%���rR���r����r��r����r ���rB���)rO���r����Zprogramr����r����r����r��r����r����r����r����Z popen_args�argr����r��r����r���r���r����subprocess_exec���s*���� zBaseEventLoop.subprocess_execc�������������C���s���|��j��S)zKReturn an exception handler, or None if the default one is in use. )rk���)rO���r���r���r����get_exception_handler���s����z#BaseEventLoop.get_exception_handlerc�������������C���s;���|�d�k �r.�t��|���r.�t�d�j�|�������|�|��_�d�S)a���Set handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz/A callable object or None is expected, got {!r})r����r1���r����rk���)rO���Zhandlerr���r���r����set_exception_handler���s���� z#BaseEventLoop.set_exception_handlerc������� ������C���s���|�j��d���}�|�s�d�}�|�j��d���}�|�d�k �rQ�t�|���|�|�j�f�}�n�d�}�d�|�k�r��|��j�d�k �r��|��j�j�r��|��j�j�|�d�<|�g�}�x��t�|���D]��}�|�d�k�r��q��|�|�}�|�d�k�r�d�j�t�j�|�����}�d �}�|�|�j ����7}�nI�|�d�k�r=d�j�t�j�|�����}�d �}�|�|�j ����7}�n�t �|���}�|�j�d�j�|�|�����q��Wt �j�d�j�|���d �|��d�S)a@��Default exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. The context parameter has the same meaning as in `call_exception_handler()`. r����z!Unhandled exception in event loopr����NFZsource_tracebackZhandle_tracebackr,���z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {}� r��>���r����r����)rr���r%���� __traceback__rt���r�����sortedr����� traceback�format_list�rstripr���r3���r����r ���r ��) rO����contextr����r����r��Z log_linesr�����value�tbr���r���r����default_exception_handler���s6���� z'BaseEventLoop.default_exception_handlerc�������������C���s����|��j��d�k�rK�y�|��j�|���Wq��t�k �rG�t�j�d�d�d��Yq��Xn��y�|��j��|��|���Wnp�t�k �r��}�zP�y#�|��j�d�d�d�|�d�|�i���Wn%�t�k �r��t�j�d �d�d��Yn�XWYd�d�}�~�Xn�Xd�S) a��Call the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerr��Tr����z$Unhandled error in exception handlerr����r#��zeException in default exception handler while handling an unexpected error in custom exception handler)rk���r&��rF���r ���r ��)rO���r#��rI���r���r���r���r�������s"���� z$BaseEventLoop.call_exception_handlerc�������������C���s!���|�j��r �d�S|��j�j�|���d�S)z3Add a Handle to _scheduled (TimerHandle) or _ready.N)� _cancelledre���r3���)rO���r���r���r���r���� _add_callback��s���� zBaseEventLoop._add_callbackc�������������C���s���|��j��|���|��j����d�S)z6Like _add_callback() but called from a signal handler.N)r(��r����)rO���r���r���r���r����_add_callback_signalsafe'��s���� z&BaseEventLoop._add_callback_signalsafec�������������C���s���|�j��r�|��j�d�7_�d�S)z3Notification that a TimerHandle has been cancelled.r���N)rf���r`���)rO���r���r���r���r����_timer_handle_cancelled,��s���� z%BaseEventLoop._timer_handle_cancelledc�������������C���sl��t��|��j���}�|�t�k�r��|��j�|�t�k�r��g��}�x3�|��j�D](�}�|�j�rY�d�|�_�q>�|�j�|���q>�Wt�j�|���|�|��_�d�|��_�nJ�xG�|��j�r��|��j�d�j�r��|��j�d�8_�t�j �|��j���}�d�|�_�q��Wd�}�|��j �s��|��j�r��d�}�n2�|��j�r)|��j�d�j�}�t �d�|�|��j������}�|��j�r|�d�k�r|��j����}�|��j�j�|���}�|��j����|�}�|�d�k�r�t�j�} �n �t�j�} �t��|���} �|�d�k�r�t�j�| �d�|�d�| ���q+| �r�t�j�| �d�|�d�|�d�| ���q+|�d�k�r+t�j�| �d �|�d�|�d���n�|��j�j�|���}�|��j�|���|��j����|��j�}�xU�|��j�r�|��j�d�}�|�j�|�k�rtPt�j �|��j���}�d�|�_�|��j �j�|���qNWt��|��j ���}�x��t�|���D]��} �|��j �j����}�|�j�r�q�|��j�rTz[�|�|��_�|��j����}�|�j����|��j����|�}�|�|��j�k�rCt�j�d �t�|���|���Wd�d�|��_�Xq�|�j����q�Wd�}�d�S)z�Run one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. Fr���r���Ng�������?zpoll took %.3f ms: %s eventsg�����@�@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds) r����rf����_MIN_SCHEDULED_TIMER_HANDLESr`����%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr'��r3���r�����heapify�heappopre���rb���Z_when�maxri���r����Z _selectorZselect�logging�INFO�DEBUGr ����logr����rj����range�popleftrt���Z_runrs���r��r���)rO���Zsched_countZ new_scheduledr���Ztimeoutr����r����r����r�����levelZneventZend_timeZntodo�ir���r���r���r����1��s����� zBaseEventLoop._run_oncec�������������C���s����y�t��j�}�t��j�}�Wn�t�k �r.�d��SYn�Xt�|���}�|��j�|�k�rN�d��St�j�}�|����}�|�r��|�d��|�f�k�r��t�j �d�|�t ���q��|�|���d�|��_�n<�|�d��|�f�k�r��t�j �d�|�t ���n�|�d����d�|��_�d��S)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF)rm����set_coroutine_wrapper�get_coroutine_wrapper�AttributeErrorro���rv���r���Z debug_wrapperr����r�����RuntimeWarning)rO����enabledZset_wrapperZget_wrapper�wrapperZcurrent_wrapperr���r���r���r�������s.���� z$BaseEventLoop._set_coroutine_wrapperc�������������C���s���|��j��S)N)r����)rO���r���r���r���r}������s����zBaseEventLoop.get_debugc�������������C���s&���|�|��_��|��j����r"�|��j�|���d��S)N)r����r{���r����)rO���r<��r���r���r���rl������s���� zBaseEventLoop.set_debug)GrR���r\���r]���rP���rS���r=���r����r����r����r����r����r����r����r����r���r����r����r����r���r����r����r����r����r����rH���rW���r|���r���ZPY34r����r{���ri���r����r����r����r����r����r����r����r����r����r����r?���r����r����r����r����r���r���r2���Z AI_PASSIVEr��r��r��r��r��r���r���r��r��r��r��r&��r����r(��r)��r*��r����r����r}���rl���r���r���r���r���r �������s����! % ! � u _ ,2c!).�__doc__rc���Zconcurrent.futuresr����r����r���r��r0��rp���r���r���r����ri���r ��rm���r����rw���r,���r���r���r���r���r���r���r3��r ����__all__r+��r,���BrokenPipeError�ConnectionResetError�ConnectionAbortedErrorZ_FATAL_ERROR_IGNOREr���r���r$���r'���r)���r:���r&���rD���rJ���ZAbstractServerrK���ZAbstractEventLoopr ���r���r���r���r����<module>���sL��� = /