관리-도구
편집 파일: futures.cpython-311.pyc
� �����VHϽ�C���������������������8����d�Z�dZddlZddlZddlZddlZddlmZ�ddl m Z �ddl mZ�ddl mZ�dd l m Z �e j��������Ze j��������Ze j��������Ze j��������Zej��������dz ��Z�G�d ��d������������ZeZd��Zd ��Zd��Zd��Zd��Zd��Zdd�d�Z �ddlZej��������xZZdS�#�e$�r�Y�dS�w�xY�w)z.A Future class similar to the one in PEP 3148.)�Future�wrap_future�isfuture�����N)�GenericAlias����)�base_futures)�events)� exceptions)�format_helpersc��������������������������e�Zd�ZdZeZdZdZdZdZ dZ dZdZdZ dd�d�Zd��Zd��Z�ee������������Zed����������������Zej��������d ����������������Zd ��Zd��Zdd�Zd ��Zd��Zd��Zd��Zd��Zdd�d�Zd��Z d��Z!d��Z"d��Z#e#Z$dS�)r���a,��This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF��loopc�����������������������|�t����������j����������������������|�_��������n||�_��������g�|�_��������|�j�������������������������������������������r-t����������j��������t����������j��������d������������������������|�_ ��������dS�dS�)z�Initialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr���) r ����_get_event_loop�_loop� _callbacks� get_debugr���� extract_stack�sys� _getframe�_source_traceback��selfr���s��� �6/opt/alt/python311/lib64/python3.11/asyncio/futures.py�__init__zFuture.__init__H���sq��������<��/�1�1�D�J�J��D�J�����:���!�!�� "�%3�%A�� �a� � �&"��&"�D�"�"�"� "�� "�����c������������������*�����t����������j��������|�������������S��N)r����_future_repr�r���s��� r����__repr__zFuture.__repr__X���s�������(��.�.�.r���c�����������������������|�j���������sd�S�|�j��������}|�j��������j����������d�||�d�}|�j��������r |�j��������|d<���|�j�����������������������������|�������������d�S�)Nz exception was never retrieved)�message� exception�future�source_traceback)�_Future__log_traceback� _exception� __class__�__name__r���r����call_exception_handler)r����exc�contexts��� r����__del__zFuture.__del__[���sx�������#�� �� �F��o����>�*�J�J�J��� �� ����!�� A�*.�*@�G�&�'�� �)�)�'�2�2�2�2�2r���c�����������������������|�j���������S�r���)r'���r ���s��� r����_log_tracebackzFuture._log_tracebackm���s�������#�#r���c������������������6�����|rt����������d�������������d|�_��������d�S�)Nz'_log_traceback can only be set to FalseF)� ValueErrorr'���)r����vals��� r���r0���zFuture._log_tracebackq���s(�������� H��F�G�G�G�$����r���c������������������6�����|�j���������}|�t����������d�������������|S�)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r����RuntimeErrorr���s��� r����get_loopzFuture.get_loopw���s"�������z���<��B�C�C�C��r���c������������������������|�j����������|�j���������}d|�_���������|S�|�j���������t����������j����������������������}nt����������j��������|�j��������������������}|�j���������|_��������d|�_���������|S�)z�Create the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. N)�_cancelled_exc�_cancel_messager ����CancelledError�__context__�r���r,���s��� r����_make_cancelled_errorzFuture._make_cancelled_error~���se���������*��%�C�"&�D���J���'��+�-�-�C�C��+�D�,@�A�A�C��-���"���� r���c�����������������������d|�_���������|�j��������t����������k����rdS�t����������|�_��������||�_��������|�������������������������������������dS�)z�Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r'����_state�_PENDING� _CANCELLEDr9����_Future__schedule_callbacks)r����msgs��� r����cancelz Future.cancel����sD������� %����;�(�"�"��5� ���"����!�!�#�#�#��tr���c�����������������������|�j���������dd����������}|sdS�g�|�j���������dd�<���|D�]"\��}}|�j�����������������������������||�|���������������#dS�)z�Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N�r-���)r���r���� call_soon)r���� callbacks�callback�ctxs��� r����__schedule_callbackszFuture.__schedule_callbacks����sn��������O�A�A�A�&� ��� ��F��������&�� >�� >�M�H�c��J� � ��4�� �=�=�=�=� >�� >r���c������������������"�����|�j���������t����������k����S�)z(Return True if the future was cancelled.)r?���rA���r ���s��� r���� cancelledzFuture.cancelled����s�������{�j�(�(r���c������������������"�����|�j���������t����������k����S�)z�Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r?���r@���r ���s��� r����donezFuture.done����s��������{�h�&�&r���c�����������������������|�j���������t����������k����r|������������������������������������}|�|�j���������t����������k����rt ����������j��������d�������������d|�_��������|�j���������|�j�����������������������������|�j ���������������������|�j ��������S�)a��Return the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.F)r?���rA���r=���� _FINISHEDr ����InvalidStateErrorr'���r(����with_traceback� _exception_tb�_resultr<���s��� r����resultz Future.result����sw��������;�*�$�$��,�,�.�.�C��I��;�)�#�#��.�/E�F�F�F�$����?�&��/�0�0��1C�D�D�D��|�r���c�����������������������|�j���������t����������k����r|������������������������������������}|�|�j���������t����������k����rt ����������j��������d�������������d|�_��������|�j��������S�)a&��Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r?���rA���r=���rQ���r ���rR���r'���r(���r<���s��� r���r$���zFuture.exception����sV��������;�*�$�$��,�,�.�.�C��I��;�)�#�#��.�/F�G�G�G�$�����r���rF���c�����������������������|�j���������t����������k����r|�j�����������������������������||�|��������������dS�|�t ����������j����������������������}|�j�����������������������������||f�������������dS�)z�Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. rF���N)r?���r@���r���rG����contextvars�copy_contextr����append)r����fnr-���s��� r����add_done_callbackzFuture.add_done_callback����sg��������;�(�"�"��J� � ��T�7� �;�;�;�;�;���%�2�4�4���O�"�"�B��=�1�1�1�1�1r���c�������������������������fd�|�j���������D���������������}t����������|�j���������������������t����������|������������z ��}|r||�j���������dd�<���|S�)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. c������������������*������g�|�]\��}}|�k�����||f��S���r`���)�.0�frJ���r\���s��� �r���� <listcomp>z/Future.remove_done_callback.<locals>.<listcomp>����s2��������*��*��*�"*�1�c�!"�b���� !�#�h�!(��r���N)r����len)r���r\����filtered_callbacks� removed_counts��� ` r����remove_done_callbackzFuture.remove_done_callback����sk������� *��*��*��*�.2�o�*��*��*����D�O�,�,�s�3E�/F�/F�F� ��� 4�!3�D�O�A�A�A���r���c�����������������������|�j���������t����������k����rt����������j��������|�j�����������d|����������������||�_��������t ����������|�_���������|�������������������������������������dS�)z�Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. �: N)r?���r@���r ���rR���rU���rQ���rB���)r���rV���s��� r���� set_resultzFuture.set_result����sX��������;�(�"�"��.�$�+�/I�/I��/I�/I�J�J�J��������!�!�#�#�#�#�#r���c������������������^����|�j���������t����������k����rt����������j��������|�j�����������d|����������������t ����������|t ����������������������r �|��������������}t����������|������������t����������u�rt����������d�������������||�_��������|j ��������|�_ ��������t����������|�_���������|�������������������������������������d|�_ ��������dS�)z�Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. ri���zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r?���r@���r ���rR���� isinstance�type� StopIteration� TypeErrorr(���� __traceback__rT���rQ���rB���r'���)r���r$���s��� r���� set_exceptionzFuture.set_exception ��s���������;�(�"�"��.�$�+�/I�/I��/I�/I�J�J�J��i��&�&�� $�!� ���I�� �?�?�m�+�+���A��B��B�� B�#���&�4�������!�!�#�#�#�#����r���c��������������#�������K����|�������������������������������������sd|�_��������|�V���|�������������������������������������st����������d�������������|������������������������������������S�)NTzawait wasn't used with future)rO����_asyncio_future_blockingr5���rV���r ���s��� r���� __await__zFuture.__await__��sU�����������y�y�{�{�� �,0�D�)��J�J�J��y�y�{�{�� @��>�?�?�?��{�{�}�}�r���r���)%r*���� __module__�__qualname__�__doc__r@���r?���rU���r(���r���r���r9���r8���rs���r'���r���r!���r.����classmethodr����__class_getitem__�propertyr0����setterr6���r=���rD���rB���rM���rO���rV���r$���r]���rg���rj���rq���rt����__iter__r`���r���r���r���r������s�����������������&��F��G��J��E����O��N�� %���O�#��"��"��"��"��"� /��/��/�3��3��3� �$��L�1�1�� �$��$���X�$����%��%����%� ����������( �� �� �� �>��>��>�)��)��)�'��'��'������"����� �04��2��2��2��2��2� ����� $�� $�� $�$��$��$�&�������H�H�Hr���r���c������������������T����� �|�j���������}�|��������������S�#�t����������$�r�Y�nw�xY�w|�j��������S�r���)r6����AttributeErrorr���)�futr6���s��� r���� _get_loopr����+��sH��������<����x�z�z������ �� �� ��� ������9�s������ � c������������������\�����|�������������������������������������rdS�|����������������������|�������������dS�)z?Helper setting the result only if the future was not cancelled.N)rM���rj���)r���rV���s��� r����_set_result_unless_cancelledr����7��s/������ �}�}��������N�N�6�����r���c����������������������t����������|�������������}|t����������j��������j��������u�rt ����������j��������|�j����������S�|t����������j��������j��������u�rt ����������j��������|�j����������S�|t����������j��������j��������u�rt ����������j��������|�j����������S�|�S�r���)rm���� concurrent�futuresr:���r ����args�TimeoutErrorrR���)r,���� exc_classs��� r����_convert_future_excr����>��su�������S� � �I��J�&�5�5�5��(�#�(�3�3� �j�(�5� 5� 5��&���1�1� �j�(�:� :� :��+�S�X�6�6�� r���c������������������L����|������������������������������������sJ��|�����������������������������������r�|�j������������������������|�j����������������������sdS�|�����������������������������������}|��|�j��������t ����������|�������������������������dS�|�����������������������������������}�|�j��������|�������������dS�)z8Copy state from a future to a concurrent.futures.Future.N) rO���rM���rD����set_running_or_notify_cancelr$���rq���r����rV���rj���)r�����sourcer$���rV���s��� r����_set_concurrent_future_stater����J��s��������;�;�=�=���=� �������� �����2�:�2�4�4������ � �"�"�I��� � � �!4�Y�!?�!?�@�@�@�@�@�������� ��f�%�%�%�%�%r���c����������������������|�������������������������������������sJ��|�����������������������������������rdS�|������������������������������������rJ��|������������������������������������r|������������������������������������dS�|������������������������������������}|�$|���������������������t����������|�������������������������dS�|������������������������������������}|���������������������|�������������dS�)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rO���rM���rD���r$���rq���r����rV���rj���)r�����destr$���rV���s��� r����_copy_future_stater����Y��s������� ��;�;�=�=���=��~�~��������y�y�{�{���?� ������$���� � � � � ��$�$�&�&� �� ����2�9�=�=�>�>�>�>�>��]�]�_�_�F��O�O�F�#�#�#�#�#r���c����������������������������t������������������������s.t������������t����������j��������j��������������������st����������d�������������t�����������������������s.t�����������t����������j��������j��������������������st����������d�������������t������������������������rt ������������������������nd�t�����������������������rt �����������������������nd�d�������fd�}����fd�}����������������������|������������������������������������|�������������dS�)a��Chain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNc������������������h�����t����������|�������������rt����������||��������������d�S�t����������|�|�������������d�S�r���)r���r����r����)r%����others��� r���� _set_statez!_chain_future.<locals>._set_state}��s>�������F���� 8��u�f�-�-�-�-�-�(���7�7�7�7�7r���c������������������������|�������������������������������������r8����u�r�������������������������������������d�S������������������������j���������������������d�S�d�S�r���)rM���rD����call_soon_threadsafe)�destination� dest_loopr�����source_loops��� ���r����_call_check_cancelz)_chain_future.<locals>._call_check_cancel���sa�������� � �"�"�� @��"�k�Y�&>�&>�� � �������0�0���?�?�?�?�?� @�� @r���c��������������������������������������������������������������r��������������������������������������rd�S�����u�r���|��������������d�S�������������������������������������rd�S�������������������������|��������������d�S�r���)rM���� is_closedr����)r����r����r����r����r����s��� ����r����_call_set_statez&_chain_future.<locals>._call_set_state���s���������!�!�#�#�� ��%�)�*=�*=�*?�*?�%��F��� �[� 8� 8��J�{�F�+�+�+�+�+��"�"�$�$�� ����*�*�:�{�F�K�K�K�K�Kr���)r���rl���r����r����r���ro���r����r]���)r����r����r����r����r����r����r����s���`` @@@r���� _chain_futurer����m��s_������������F����D�J�v�/9�/A�/H�%J��%J��D��B�C�C�C��K� � ��I��K�4>�4F�4M�*O��*O��I��G�H�H�H�'/��'7�'7�A�)�F�#�#�#�T�K�*2�;�*?�*?�I� �+�&�&�&�T�I�8��8��8�@��@��@��@��@��@��@� L�� L�� L�� L�� L�� L�� L�� L���!�!�"4�5�5�5� ���_�-�-�-�-�-r���r ���c�����������������������t����������|�������������r|�S�t����������|�t����������j��������j��������������������s J�d|������������������|�t����������j����������������������}|�����������������������������������}t����������|�|�������������|S�)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got ) r���rl���r����r����r���r ���r���� create_futurer����)r%���r���� new_futures��� r���r���r������s�������������� ��f�j�0�7�8�8��A��A�@�f�@�@�A��A�8��|��%�'�'���#�#�%�%�J��&�*�%�%�%��r���) rw����__all__�concurrent.futuresr����rY����loggingr����typesr�����r���r ���r ���r���r���r@���rA���rQ����DEBUG�STACK_DEBUGr���� _PyFuturer����r����r����r����r����r����r����_asyncio�_CFuture�ImportErrorr`���r���r����<module>r�������s������4��4������������������������� � � � ��������������������������������������������������������������� ���� �� � $� ��"� ���m�a���F��F��F��F��F��F��F��F�T� � � �� �� ������ �� �� �&��&��&�$��$��$�().��).��).�X�!%�� �� �� �� �� �(��O�O�O� �!��'�F�X�X�X�� ��� �� �� ��D�D� ���s����B��B�B