Current File : //usr/lib64/python3.9/site-packages/gi/__pycache__/_ossighelper.cpython-39.pyc |
a
b�^� � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ ddl m
Z
dd� Zdaed d
� �Z
e
jZe�ej�eju r�eej�ZndZdd
� Zedd� �Zdd� Zg adaedd� �ZdS )� )�print_functionN)�closing�contextmanager� )�_gic C sn t | d�r| �d� nTzddl}W n ty< td��Y n.0 | �� }|�||j�}|�||j||jB � dS )z�Ensures that the socket is not inherited by child processes
Raises:
EnvironmentError
NotImplementedError: With Python <3.4 on Windows
�set_inheritableFr Nz+Not implemented for older Python on Windows) �hasattrr �fcntl�ImportError�NotImplementedError�filenoZF_GETFDZF_SETFDZ
FD_CLOEXEC)�sockr �fd�flags� r �5/usr/lib64/python3.9/site-packages/gi/_ossighelper.py�ensure_socket_not_inheritable s
�
r Fc # s� t rdV dS ddlm� t�� \�} t����� t| ���X �| fD ]}|�d� t|� qFzt� | �
� �}W n2 ty� dV Y W d � W d � dS 0 da � �fdd�}z�tj
dkrԈ j���
� �}n� j���
� �}� �|� j� jj� jjB � jjB � jjB |�}zdV W � �|� n� �|� 0 W t� |�}|| �
� k�rXt� |� da n(t� |�}|| �
� k�r�t� |� da 0 W d � n1 �s�0 Y W d � n1 �s�0 Y dS ) 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
sV |� j @ rNzt��d��W S tyH } zt|� W Y d }~dS d }~0 0 dS dS d S )Nr FT)ZIO_IN�boolZrecv�EnvironmentError�print)�sourceZ condition�e�r Zread_socketr r �
signal_notify\ s
z'wakeup_on_signal.<locals>.signal_notify�nt)�_wakeup_fd_is_activeZ
gi.repositoryr �socketZ
socketpairr Zsetblockingr �signal�
set_wakeup_fdr �
ValueError�os�nameZ IOChannelZwin32_new_socketZunix_newZio_add_watchZPRIORITY_DEFAULTZIOCondition�INZHUPZNVALZERRZ
source_remove)Zwrite_socketr
Zorig_fdr ZchannelZ source_idZwrite_fdr r r �wakeup_on_signal7 sV
����
�
r$ ���c C s t �t j�t ju ott j�tkS )z?Returns if on SIGINT the default Python handler would be called)r � getsignal�SIGINT�default_int_handler�PyOS_getsig�startup_sigint_ptrr r r r �sigint_handler_is_default� s �r+ c
c s� t � s
J �t�tj| � ttj�}z8dV W t�tj�| u r�ttj�|kr�t�tjtj� n0t�tj�| u r�ttj�|kr�t�tjtj� 0 dS )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)r+ r r'