f.ddlmZddlZddlZddlZddlZddlmZmZddl m Z dZ da edZ e jZej ej"ej$ureej"Znd Zd Zed Zd Zgadaed Zy))print_functionN)closingcontextmanager)_gic&t|dr|jdy ddl}|j}|j||j}|j||j ||j zy#t$r tdwxYw)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) hasattrr fcntlfilenoF_GETFDF_SETFD FD_CLOEXEC ImportErrorNotImplementedError)sockr fdflagss 1/usr/lib/python3/dist-packages/gi/_ossighelper.pyensure_socket_not_inheritablerst&' U# E  BKKEMM2E KKEMM553C3C+C D  ?%=? ? ?s A;;BFc#Ktrdyddlmtj\}t 5t |5|fD]}|j dt|  tj|j}dafd} tjdk(r*jjj}n)jj!j}j#|j$j&j(j&j*zj&j,zj&j.z|} dj1| tj|}||jk7rtj|da ddddddy#t$rdYddddddywxYw#j1|wxYw#tj|}||jk7rtj|dawxYw#1swYxYw#1swYyxYww)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. 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 tjdSy#t$r}t |Yd}~yd}~wwxYw)NrF)IO_INboolrecvEnvironmentErrorprint)source conditioner read_sockets r signal_notifyz'wakeup_on_signal..signal_notify\sK4::%! 0 0 344  (!!H !s- A  AA nt)_wakeup_fd_is_active gi.repositoryrsocket socketpairr setblockingrsignal set_wakeup_fdr ValueErrorosname IOChannelwin32_new_socketunix_new io_add_watchPRIORITY_DEFAULT IOConditionINHUPNVALERR source_remove) write_socketrorig_fdr#channel source_idwrite_fdrr"s @@rwakeup_on_signalr?7s/ " & 1 1 3K  1)w|41) ,/ 0D   U # )$ / 0 (**<+>+>+@AG $(   )ww$..99&&(*..11+2D2D2FG))%%!!$$t'7'7';';;!!&&')-)9)9)=)=> I  .""9-++G4H<..00$$X.#( c1)1)1)   1)1)1) D""9-++G4H<..00$$X.#( c1)1)1)1)s4I1 I%&I+#GICH5G?9H ?I I% I1 G<)I*I%2 I1;G<<I?HHAIII" I%%I.*I1ctjtjtjuxr t tjt k(S)z?Returns if on SIGINT the default Python handler would be called)r* getsignalSIGINTdefault_int_handler PyOS_getsigstartup_sigint_ptrrsigint_handler_is_defaultrIs=   V]] +v/I/I I =  &*< <>rHc#KtsJtjtj|ttj} dtjtj|urPttj|k(r3tjtjtj yyy#tjtj|urPttj|k(r3tjtjtj wwwxYww)zContext 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)handlersig_ptrs r&sigint_handler_set_and_restore_defaultrMs % && & MM&--)&--(GE   FMM *g 5FMM*g5 MM&--)C)C D6 66  FMM *g 5FMM*g5 MM&--)C)C D6 6s A E CA6EA7D>>EcDtjjdk(S)z@Returns True in case the function is called from the main thread MainThread) threadingcurrent_threadr.rGrHris_main_threadrRs  # # % * *l ::rHc#KtsdytsHtr=tj| dtj }t r|yydydad}tj| t |5ddddt r%tjtjdytj y#tj }t r|wwxYw#1swYpxYw#t r%tjtjdwtj wxYww)aInstalls 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. NFcFtrydatjy)NT)_sigint_called_callback_stackpop)sig_numframes rsigint_handlerz0register_sigint_fallback..sigint_handlers  rH) rRrIrVappendrWrUrMr*rDrC)callbackcbrZs rregister_sigint_fallbackr^s.    $ &   " "8 , $((*!D  N 8$" 3N C      & &v}}d ;    !5%((*!D"&     & &v}}d ;    !sN5ECAE? D C>D AE$C;;E>DD AE  E) __future__rr-r'r*rP contextlibrrrrr%r? pyos_getsigrErBrCrDrFrIrMrRrVrUr^rGrHrrcs & .E, F)F)Roo 6FMM"f&@&@@$V]]3>EE&; <"<"rH