3 <_!@sddlmZddlZddlZddlZddlZddlZddlZddlm Z m Z ddZ da e ddZ d d ZeZejZeje_ejge_ejejejkreejZndZd d Ze ddZddZgadae ddZdS))print_functionN)closingcontextmanagerc Cspt|dr|jdnVy ddl}Wntk r>tdYn.X|j}|j||j}|j||j||jBdS)zEnsures 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) hasattrrfcntl ImportErrorNotImplementedErrorfilenoZF_GETFDZF_SETFDZ FD_CLOEXEC)sockrfdflagsr$/usr/lib64/python3.6/_ossighelper.pyensure_socket_not_inheritables    rFc '#strdVdSddlmtjdkp4tjddd k}ttd}| sL| rVdVdStj \}t "t | x"|gD]}|j d t |qWyt j|j}Wntk rdVdSXd afd d }zxtjdkrjjj}njjj}j|jjjjjBjjBjjB|}z dVWdj|XWdt j|}||jkrzt j|d aXWdQRXWdQRXdS)aA 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 socketpairFTcsN|j@rFytjdStk r@}z t|dSd}~XnXdSdSdS)NFT)ZIO_INboolZrecvEnvironmentErrorprint)sourceZ conditione)r read_socketrr signal_notifyis z'wakeup_on_signal..signal_notify)rr)_wakeup_fd_is_activeZ gi.repositoryrosnamesys version_inforsocketrrZ setblockingrsignal set_wakeup_fdr ValueErrorZ IOChannelZwin32_new_socketZunix_newZ io_add_watchZPRIORITY_DEFAULTZ IOConditionINZHUPZNVALZERRZ source_remove) Zset_wakeup_fd_supports_socketZhas_socketpairZ write_socketr Zorig_fdrZchannelZ source_idZwrite_fdr)rrrwakeup_on_signal8sL            r)cCsJtjdkrtjddtjStjdkr.sigint_handler) r6r3r8appendr9r7r4r%r0r/)callbackcbr;rrrregister_sigint_fallbacks,     r?)Z __future__rr r"r$r%r+r5 contextlibrrrrr)r-Zpydllr1Zc_void_pZrestypeZc_intZargtypesr.r/r0r2r3r4r6r8r7r?rrrrs0  V