Current File : //usr/lib/python3/dist-packages/gi/__pycache__/_ossighelper.cpython-312.pyc
�

��f���.�ddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
d�Zda	ed��Z
e
jZej ej"�ej$ureej"�Znd	Zd
�Zed��Zd�Zgadaed
��Zy)�)�print_functionN)�closing�contextmanager�)�_gic�&�t|d�r|jd�y	ddl}|j�}|j||j�}|j||j
||jz�y#t$rtd��wxYw)z�Ensures that the socket is not inherited by child processes

    Raises:
        EnvironmentError
        NotImplementedError: With Python <3.4 on Windows
    �set_inheritableFrNz+Not implemented for older Python on Windows)	�hasattrr	�fcntl�fileno�F_GETFD�F_SETFD�
FD_CLOEXEC�ImportError�NotImplementedError)�sockr�fd�flagss    �1/usr/lib/python3/dist-packages/gi/_ossighelper.py�ensure_socket_not_inheritablers����t�&�'����U�#�	E��
����B��K�K��E�M�M�2�E��K�K��E�M�M�5�5�3C�3C�+C�D��
�	?�%�=�?�
?�	?�s�A;�;BFc#����K�trd��yddlm�tj�\�}t��5t|�5�|fD]}|j
d�t|�� 	tj|j��}da��fd�}	tjdk(r*�jj�j��}n)�jj!�j��}�j#|�j$�j&j(�j&j*z�j&j,z�j&j.z|�}	d���j1|�	tj|�}||j�k7rtj|�da	ddd�ddd�y#t$rd��Yddd�ddd�ywxYw#�j1|�wxYw#tj|�}||j�k7rtj|�dawxYw#1swY��xYw#1swYyxYw�w)a�A decorator for functions which create a glib event loop to keep
    Python signal handlers working while the event loop is idling.

    In case an OS signal is received will wake the default event loop up
    shortly so that any registered Python signal handlers registered through
    signal.signal() can run.

    In case the wrapped function is not called from the main thread it will be
    called as is and it will not wake up the default loop for signals.
    Nr)�GLibFTc���|�jzr	t�jd��Sy#t$r}t	|�Yd}~yd}~wwxYw)NrF)�IO_IN�bool�recv�EnvironmentError�print)�source�	condition�er�read_sockets   ��r�
signal_notifyz'wakeup_on_signal.<locals>.signal_notify\sK����4�:�:�%�!��� 0� 0�� 3�4�4���(�!��!�H� ��!�s�-�	A�A�A�nt)�_wakeup_fd_is_active�
gi.repositoryr�socket�
socketpairr�setblockingr�signal�
set_wakeup_fdr�
ValueError�os�name�	IOChannel�win32_new_socket�unix_new�io_add_watch�PRIORITY_DEFAULT�IOCondition�IN�HUP�NVAL�ERR�
source_remove)	�write_socketr�orig_fdr#�channel�	source_id�write_fdrr"s	       @@r�wakeup_on_signalr?7s/������
��"� &� 1� 1� 3��K��	��	�1)�w�|�4�1)� �,�/�	0�D����U�#�)�$�/�	0�	(��*�*�<�+>�+>�+@�A�G�$(� �		�	)��w�w�$���.�.�9�9��&�&�(�*���.�.�1�1�+�2D�2D�2F�G���)�)���%�%��!�!�$�$�t�'7�'7�';�';�;��!�!�&�&�'�)-�)9�)9�)=�)=�>���I�
.���"�"�9�-��+�+�G�4�H��<�.�.�0�0��$�$�X�.�#(� �c1)�1)�1)���	���1)�1)�1)�	��D�"�"�9�-���+�+�G�4�H��<�.�.�0�0��$�$�X�.�#(� ��c1)�1)��1)�1)�s��4I1�I%�&I�+#G�I�CH�5G?�9H�?I�I%�	I1�
G<�)I�*I%�2	I1�;G<�<I�?H�H�AI�I�I"	�I%�%I.�*I1���c��tjtj�tjuxr t	tj�t
k(S)z?Returns if on SIGINT the default Python handler would be called)r*�	getsignal�SIGINT�default_int_handler�PyOS_getsig�startup_sigint_ptr��r�sigint_handler_is_defaultrI�s=��
���V�]�]�+�v�/I�/I�I�
=���
�
�&�*<�<�>rHc#�K�t�sJ�tjtj|�ttj�}	d��tjtj�|urPttj�|k(r3tjtjtj
�yyy#tjtj�|urPttj�|k(r3tjtjtj
�wwwxYw�w)z�Context manager for saving/restoring the SIGINT handler default state.

    Will only restore the default handler again if the handler is not changed
    while the context is active.
    N)rIr*rCrErBrD)�handler�sig_ptrs  r�&sigint_handler_set_and_restore_defaultrM�s�����%�&�&�&�
�M�M�&�-�-��)��&�-�-�(�G�E�
����F�M�M�*�g�5��F�M�M�*�g�5��M�M�&�-�-��)C�)C�D�6�6��6���F�M�M�*�g�5��F�M�M�*�g�5��M�M�&�-�-��)C�)C�D�6�6�s �A
E�
C�A6E�A7D>�>Ec�D�tj�jdk(S)z@Returns True in case the function is called from the main thread�
MainThread)�	threading�current_threadr.rGrHr�is_main_threadrR�s���#�#�%�*�*�l�:�:rHc#�K�t�sd��yt�sHtr=tj|�	d��tj	�}t
r|�yyd��ydad�}tj|�	t
|�5d��ddd�t
r%tjtjd�ytj	�y#tj	�}t
r|�wwxYw#1swY�pxYw#t
r%tjtjd�wtj	�wxYw�w)a�Installs a SIGINT signal handler in case the default Python one is
    active which calls 'callback' in case the signal occurs.

    Only does something if called from the main thread.

    In case of nested context managers the signal handler will be only
    installed once and the callbacks will be called in the reverse order
    of their registration.

    The old signal handler will be restored in case no signal handler is
    registered while the context is active.
    NFc�F�trydatj��y)NT)�_sigint_called�_callback_stack�pop)�sig_num�frames  r�sigint_handlerz0register_sigint_fallback.<locals>.sigint_handler�s����������rH)
rRrIrV�appendrWrUrMr*rDrC)�callback�cbrZs   r�register_sigint_fallbackr^�s����.��
��$�&��
�"�"�8�,�
��$�(�(�*��!��D�	�
���N� ����8�$�"�
3�N�
C�	��	���&�&�v�}�}�d�;����!��5%�(�(�*��!��D�"��&	�	����&�&�v�}�}�d�;����!�sN�5E�C�AE�?D
�
C>�D
�AE�$C;�;E�>D�D
�
AE�E)�
__future__rr-r'r*rP�
contextlibrr�rrr%r?�pyos_getsigrErBrCrDrFrIrMrRrVrUr^rGrHr�<module>rcs��� &�	�
�
��.��E�,���
�F)��F)�R�o�o���6���F�M�M�"�f�&@�&@�@�$�V�]�]�3����>��E��E�&;������<"��<"rH