+
    Ki  c                   s    ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIH	t	  ! R R]P                  4      t ! R R4      t]! 4       t]P                  4        R	R
/R R lltRR
/R R lltR# )i    N)CallableOptional)GLib)loggerc                   sJ   a a ] tR t^t oRR/V 3R lltRR ltR tRtVtV ;t	# )	AsyncCallcallback_targetNc               s(  < RV n         \        P                  ! 4       V n        \        SV `  V P                  WER7       Wn        V'       g
   R V n        MV P                  W#4      V n        VP                  RR4      V n        V P                  4        R# )zExecute `function` in a new thread then schedule `callback` for
execution in the main loop. If 'callback_target' is a widget and it is destroyed
in the meantime, the callback is cancelled.
N)targetargskwargsc                     R # N re   &&5/usr/lib/python3.14/site-packages/lutris/util/jobs.py<lambda>Z$AsyncCall.__init__.<locals>.<lambda>   s        daemonT)callback_task	threadingZEventstop_requestZsuper__init__r   functioncallback_protect_callbackZpopr   Zstart)selffuncr   r   r   r   	__class__s   &&&$*,r   r   ZAsyncCall.__init__   sn    
 "%OO-$F-DM 228MDMjj40

r   c                s   a aa V'       g!   \        SR4      '       d   SP                  MRpV'       d3   \        VR4      '       d!   V 3R lpVV3R lpVP                  V4      oV# S# )a  Wraps and hooks up an on-destroyed handler on the callback_target that
removes the callback; this prevents an AsyncJob from completing on a
destroyed widget, which can cause a crash.

If no callback_target is given, this will use the receiver of the callback
(if it has one).__self__Ncall_when_destroyedc                  s   < R  S n         R# )c                 r	   r
   r   r   r   r   r   Z=AsyncCall._protect_callback.<locals>.unhook.<locals>.<lambda>,   s    Tr   N)r   r   s   r   unhookZ+AsyncCall._protect_callback.<locals>.unhook)   s     !2r   c                 s&   < S! 4        S! W4       R # r
   r   )r   r   r   disconnecters   &&r   fireZ)AsyncCall._protect_callback.<locals>.fire.   s     r   )hasattrr   r   )r   r   r   r!   r#   r"   s   ff&  @r   r   ZAsyncCall._protect_callback   sX     3:8Z3P3Ph//VZOw8MNN2
 +>>vFLKOr   c                sR   R pR p V P                   ! V/ VB p\        V P                  W44      V n        R #   \         dg   p\        P                  ! RT P                   \	        T4      T4       Tp\
        P                  ! 4       w  rgp\        P                  ! T4        R p?LR p?ii ; i)Nz%Error while completing task %s: %s %s)r   Z	Exceptionr   errorZtypesysZexc_info	tracebackZprint_tbschedule_at_idler   r   )	r   akwZresultr%   ZexZ_ex_typeZ	_ex_valueZtraces	   &*,      r   r   ZAsyncCall.target9   s    	&]]A,,F .dmmVK  	&LL@$--QUVXQY[]^E),&Hu%%		&s   5 B& AB!!B&)r   r   r   r   r   r
   )
__name__
__module____qualname____firstlineno__r   r   r   __static_attributes____classdictcell__Z__classcell__)r   __classdict__s   @@r   r   r      s"     d "8L Lr   r   c                   s   a  ] tR t^Ht o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
RtV tR# )IdleTaska  This class provides a safe interface for cancelling idle tasks and timeouts;
this will simply do nothing after being used once, and once the task completes,
it will also do nothing.

These objects are returned by the schedule methods below, which disconnect
them when appropriate.c                   < V ^8  d   QhRR/#    returnNr   formatr1      "r   __annotate__IdleTask.__annotate__P   s     # #$ #r   c                s"    RV n         RV n        R# )zInitializes a task with no connection to a source, but also not completed; this can be
connected to a source via the connect() method, unless it is completed first.NF)	source_id_is_completedr       &r   r   ZIdleTask.__init__P   s     )-"r   c                r3   r4   r   r7   r9   r   r:   r;   V   s      D r   c                s    V P                   e3   \        P                  ! V P                   4       V P                  4        R# R# )zKCall this to prevent the idle task from running, if it has not already run.N)r<   r   Zsource_remove
disconnectr    r>   r   
unscheduleZIdleTask.unscheduleV   s-    >>%t~~.OO &r   c                s    < V ^8  d   QhRS[ /# r5   r6   boolr7   r9   r   r:   r;   \   s     " "d "r   c                s    V P                   # )zSTrue if the idle task has completed; that is, if mark_completed() was called on it.)r=   r    r>   r   is_completedZIdleTask.is_completed\   s    !!!r   c                r3   r4   r   r7   r9   r   r:   r;   `   s     ' 'D 'r   c                s:    V P                   '       g	   Wn        R# R# )zjConnects this task to a source to be unscheduled; but if the task is already
completed, this does nothing.Nr=   r<   )r   r<   r   r   connectZIdleTask.connect`   s     !!!&N "r   c                r3   r4   r   r7   r9   r   r:   r;   f   s      D r   c                s    RV n         R# )z<Break the link to the idle task, so it can't be unscheduled.N)r<   r    r>   r   r?   ZIdleTask.disconnectf   s	    r   c                r3   r4   r   r7   r9   r   r:   r;   j   s       r   c                s4    RV n         V P                  4        R# )z4Marks the task as completed, and also disconnect it.TN)r=   r?   r    r>   r   mark_completedZIdleTask.mark_completedj   s    !r   rE   N)r+   r,   r-   r.   Z__doc__r   r@   rD   rF   r?   rG   r/   r0   )r1   s   @r   r2   r2   H   sF     # # " "' '  r   r2   delay_seconds        c                sJ    V ^8  d   QhR\         R,          R\        R\        /# )r5   r   rH   r6   ).N)r    floatr2   r8      "r   r:   r:   u   s'      8I. e V^ r   c               D  a a \        4       oR V V3R llp\        S R4      '       d   S P                  MRpV'       d   WCn        VR8  d,   \        VR,          4      p\        P
                  ! WS.VO5!  pM\        P                  ! V.VO5!  pSP                  V4       S# )zSchedules a function to run at idle time, once. You can specify a delay in seconds
before it runs.
Returns an object to prevent it running.c                $    V ^8  d   QhR\         /# rA   rB   rK   rL   r   r:   Z&schedule_at_idle.<locals>.__annotate__|   s      T r   c                  sf   <  S! V / VB   SP                  4        R #   SP                  4        i ; iFr?   )r)   r*   r   tasks   *,r   wrapperZ!schedule_at_idle.<locals>.wrapper|   s+    	!NrNOODOOs    0r   NrI     r2   r$   r   Zintr   Ztimeout_addZidle_addrF   )r   rH   r   rR   handler_objectmillisecondsr<   rQ      f$*    @r   r(   r(   u   s    
 :D  '.dJ&?&?T]]TN)=4/0$$\BTB	MM'1D1	LLKr   interval_secondsc                sV    V ^8  d   QhR\         R\        3,          R\        R\        /# )r5   r   .rX   r6   )r    rC   rJ   r2   rK   rL   r   r:   r:      s1      
39
  	r   c               rM   )zSchedules a function to run at idle time, over and over until it returns False.
It can be repeated at an interval in seconds, which will also delay it's first invocation.
Returns an object to stop it running.c                rN   rA   rB   rK   rL   r   r:   Z0schedule_repeating_at_idle.<locals>.__annotate__   s     " "T "r   c                  s   < R p S! V / VB pTV'       g   SP                  4        # #   T'       g   SP                  4        i i ; irO   rP   )r)   r*   Zrepeatr   rQ   s   *, r   rR   Z+schedule_repeating_at_idle.<locals>.wrapper   sB    	"1^^F! 6! s	   	( Ar   NrI   rS   rT   )r   rX   r   rR   rU   rV   r<   rQ   rW   r   schedule_repeating_at_idlerY      s     :D" " '.dJ&?&?T]]TN)3+d23$$\BTB	MM'1D1	LLKr   )r&   r   r'   Ztypingr    r   Zgi.repositoryr   Zlutris.util.logr   ZThreadr   r2   ZCOMPLETED_IDLE_TASKrG   r(   rY   r   r   r   <module>rZ      sm    
   %  ":L	   :Lz% %R j   " " $c 8 " r   