3
<_! @ s d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z m
Z
dd Zdae
dd Z
d d
Ze ZejZeje_ejge_ejejejkreejZndZdd
Ze
dd Zdd Zg adae
dd ZdS ) )print_functionN)closingcontextmanagerc
C sp t | dr| jd nVyddl}W n tk
r> tdY n.X | j }|j||j}|j||j||jB dS )zEnsures 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 fcntlImportErrorNotImplementedErrorfilenoZF_GETFDZF_SETFDZ
FD_CLOEXEC)sockr fdflags r $/usr/lib64/python3.6/_ossighelper.pyensure_socket_not_inheritable s
r Fc ' # s t rdV dS ddlm tjdkp4tjdd d
k} ttd}| sL| rVdV dS tj \}t
" t
| x"|gD ]}|jd t| qW yt
j|j }W n tk
r dV dS X d
a fdd}zxtjdk r jjj }n jjj } j| j jj jjB jjB jjB |}z
dV W d j| X W dt
j|}||j krzt
j| d a X W dQ R X W dQ R X 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.
Works on Windows but needs Python 3.5+.
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 )GLibnt
socketpairFTc sN | j @ rFytjdS tk
r@ } zt| dS d }~X nX dS dS d S )N FT)ZIO_INboolZrecvEnvironmentErrorprint)sourceZ conditione)r read_socketr r
signal_notifyi s
z'wakeup_on_signal.