Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 \…¿ã@s|dZddlZddlZddlmZddlmZ ddl m Z ddl m ZmZyddlmZWn ek rxddlmZYnXdd d d d d dddddddddddddddgZejZejZejZejZejZy ejZ Wne!k rèdZ YnXej"Z"[da#da$dd„Z%dd„Z&eZ'dd„ZGd d!„d!ƒZ(e(Z)Gd"d „d ƒZ*Gd#d„dƒZ+Gd$d„de+ƒZ,Gd%d„dƒZ-Gd&d„dƒZ.Gd'd„de/ƒZ0eƒj1Z2e2ƒd@d)d*„Z3eƒa4iZ5iZ6e ƒZ7Gd+d„dƒZ8Gd,d„de8ƒZ9Gd-d.„d.e8ƒZ:Gd/d0„d0e8ƒZ;d1d „Ze>Z?d3d4„Z@d5d „ZAdd6lmBZBe:ƒaCd7d8„ZDd9d:„ZEd;d „ZFyddd?„ZJdS)Az;Thread module emulating a subset of Java's threading model.éN)Ú monotonic)Ú format_exc)ÚWeakSet)ÚisliceÚcount)ÚdequeÚ get_identÚ active_countÚ ConditionÚcurrent_threadÚ enumerateÚ main_threadÚ TIMEOUT_MAXÚEventÚLockÚRLockÚ SemaphoreÚBoundedSemaphoreÚThreadÚBarrierÚBrokenBarrierErrorÚTimerÚ ThreadErrorÚ setprofileÚsettraceÚlocalÚ stack_sizecCs|adS)z¸Set a profile function for all threads started from the threading module. The func will be passed to sys.setprofile() for each thread, before its run() method is called. N)Ú _profile_hook)Úfunc©rú!/usr/lib64/python3.6/threading.pyr2scCs|adS)z´Set a trace function for all threads started from the threading module. The func will be passed to sys.settrace() for each thread, before its run() method is called. N)Ú _trace_hook)rrrr r<scOstdkrt||ŽSt||ŽS)a2Factory function that returns a new reentrant lock. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it. N)Ú_CRLockÚ_PyRLock)ÚargsÚkwargsrrr rJs  c@sVeZdZdZdd„Zdd„Zddd „ZeZd d „Zd d „Z dd„Z dd„Z dd„Z dS)Ú_RLocka,This class implements reentrant lock objects. A reentrant lock must be released by the thread that acquired it. Once a thread has acquired a reentrant lock, the same thread may acquire it again without blocking; the thread must release it once for each time it has acquired it. cCstƒ|_d|_d|_dS)Nr)Ú_allocate_lockÚ_blockÚ_ownerÚ_count)Úselfrrr Ú__init__asz_RLock.__init__cCs^|j}yt|j}Wntk r(YnXd|jjƒr:dnd|jj|jj||j t t |ƒƒfS)Nz)<%s %s.%s object owner=%r count=%d at %s>ÚlockedZunlocked) r)Ú_activeÚnameÚKeyErrorr(r-Ú __class__Ú __module__Ú __qualname__r*ÚhexÚid)r+Úownerrrr Ú__repr__fsz_RLock.__repr__TécCsDtƒ}|j|kr"|jd7_dS|jj||ƒ}|r@||_d|_|S)aAcquire a lock, blocking or non-blocking. When invoked without arguments: if this thread already owns the lock, increment the recursion level by one, and return immediately. Otherwise, if another thread owns the lock, block until the lock is unlocked. Once the lock is unlocked (not owned by any thread), then grab ownership, set the recursion level to one, and return. If more than one thread is blocked waiting until the lock is unlocked, only one at a time will be able to grab ownership of the lock. There is no return value in this case. When invoked with the blocking argument set to true, do the same thing as when called without arguments, and return true. When invoked with the blocking argument set to false, do not block. If a call without an argument would block, return false immediately; otherwise, do the same thing as when called without arguments, and return true. When invoked with the floating-point timeout argument set to a positive value, block for at most the number of seconds specified by timeout and as long as the lock cannot be acquired. Return true if the lock has been acquired, false if the timeout has elapsed. r8)rr)r*r(Úacquire)r+ÚblockingÚtimeoutÚmeÚrcrrr r9us z_RLock.acquirecCs<|jtƒkrtdƒ‚|jd|_}|s8d|_|jjƒdS)amRelease a lock, decrementing the recursion level. If after the decrement it is zero, reset the lock to unlocked (not owned by any thread), and if any other threads are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. If after the decrement the recursion level is still nonzero, the lock remains locked and owned by the calling thread. Only call this method when the calling thread owns the lock. A RuntimeError is raised if this method is called when the lock is unlocked. There is no return value. zcannot release un-acquired lockr8N)r)rÚ RuntimeErrorr*r(Úrelease)r+rrrr r?›s  z_RLock.releasecCs |jƒdS)N)r?)r+ÚtÚvÚtbrrr Ú__exit__²sz_RLock.__exit__cCs|jjƒ|\|_|_dS)N)r(r9r*r))r+Ústaterrr Ú_acquire_restore·s z_RLock._acquire_restorecCs<|jdkrtdƒ‚|j}d|_|j}d|_|jjƒ||fS)Nrzcannot release un-acquired lock)r*r>r)r(r?)r+rr6rrr Ú _release_save»s  z_RLock._release_savecCs |jtƒkS)N)r)r)r+rrr Ú _is_ownedÅsz_RLock._is_ownedNéÿÿÿÿ)TrH) Ú__name__r2r3Ú__doc__r,r7r9Ú __enter__r?rCrErFrGrrrr r&Ws $ r&c@steZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z ddd„Z ddd„Z ddd„Z dd„ZeZdS)r ajClass that implements a condition variable. A condition variable allows one or more threads to wait until they are notified by another thread. If the lock argument is given and not None, it must be a Lock or RLock object, and it is used as the underlying lock. Otherwise, a new RLock object is created and used as the underlying lock. NcCs–|dkrtƒ}||_|j|_|j|_y |j|_Wntk rDYnXy |j|_Wntk rfYnXy |j|_Wntk rˆYnXtƒ|_ dS)N) rÚ_lockr9r?rFÚAttributeErrorrErGÚ_dequeÚ_waiters)r+Úlockrrr r,×s$   zCondition.__init__cCs |jjƒS)N)rLrK)r+rrr rKïszCondition.__enter__cGs |jj|ŽS)N)rLrC)r+r$rrr rCòszCondition.__exit__cCsd|jt|jƒfS)Nz)rLÚlenrO)r+rrr r7õszCondition.__repr__cCs|jjƒdS)N)rLr?)r+rrr rFøszCondition._release_savecCs|jjƒdS)N)rLr9)r+Úxrrr rEûszCondition._acquire_restorecCs"|jjdƒr|jjƒdSdSdS)NrFT)rLr9r?)r+rrr rGþs  zCondition._is_ownedcCs¬|jƒstdƒ‚tƒ}|jƒ|jj|ƒ|jƒ}d}z:|dkrN|jƒd}n |dkrd|jd|ƒ}n |jdƒ}|S|j|ƒ|s¦y|jj|ƒWnt k r¤YnXXdS)akWait until notified or until a timeout occurs. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another thread, or until the optional timeout occurs. Once awakened or timed out, it re-acquires the lock and returns. When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). When the underlying lock is an RLock, it is not released using its release() method, since this may not actually unlock the lock when it was acquired multiple times recursively. Instead, an internal interface of the RLock class is used, which really unlocks it even when it has been recursively acquired several times. Another internal interface is then used to restore the recursion level when the lock is reacquired. zcannot wait on un-acquired lockFNTr) rGr>r'r9rOÚappendrFrEÚremoveÚ ValueError)r+r;ÚwaiterZ saved_stateZgotitrrr Úwaits*   zCondition.waitcCs\d}|}|ƒ}xH|sV|dk rD|dkr0tƒ|}n|tƒ}|dkrDP|j|ƒ|ƒ}qW|S)zÜWait until a condition evaluates to True. predicate should be a callable which result will be interpreted as a boolean value. A timeout may be provided giving the maximum time to wait. Nr)Ú_timerW)r+Z predicater;ÚendtimeZwaittimeÚresultrrr Úwait_for7s    zCondition.wait_forr8c Csj|jƒstdƒ‚|j}tt||ƒƒ}|s,dSx8|D]0}|jƒy|j|ƒWq2tk r`Yq2Xq2WdS)aKWake up one or more threads waiting on this condition, if any. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the threads waiting for the condition variable; it is a no-op if no threads are waiting. z!cannot notify on un-acquired lockN)rGr>rOrNÚ_islicer?rTrU)r+ÚnZ all_waitersZwaiters_to_notifyrVrrr ÚnotifyNs  zCondition.notifycCs|jt|jƒƒdS)z¯Wake up all threads waiting on this condition. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)r^rQrO)r+rrr Ú notify_alleszCondition.notify_all)N)N)N)r8)rIr2r3rJr,rKrCr7rFrErGrWr[r^r_Z notifyAllrrrr r Ës   0   c@s8eZdZdZd dd„Zddd„ZeZd d „Zd d „ZdS)raGThis class implements semaphore objects. Semaphores manage a counter representing the number of release() calls minus the number of acquire() calls, plus an initial value. The acquire() method blocks if necessary until it can return without making the counter negative. If not given, value defaults to 1. r8cCs&|dkrtdƒ‚ttƒƒ|_||_dS)Nrz$semaphore initial value must be >= 0)rUr rÚ_condÚ_value)r+Úvaluerrr r,}s zSemaphore.__init__TNc Cs˜| r|dk rtdƒ‚d}d}|j�jxb|jdkrv|s8P|dk rh|dkrTtƒ|}n|tƒ}|dkrhP|jj|ƒq(W|jd8_d}WdQRX|S)aÔAcquire a semaphore, decrementing the internal counter by one. When invoked without arguments: if the internal counter is larger than zero on entry, decrement it by one and return immediately. If it is zero on entry, block, waiting until some other thread has called release() to make it larger than zero. This is done with proper interlocking so that if multiple acquire() calls are blocked, release() will wake exactly one of them up. The implementation may pick one at random, so the order in which blocked threads are awakened should not be relied on. There is no return value in this case. When invoked with blocking set to true, do the same thing as when called without arguments, and return true. When invoked with blocking set to false, do not block. If a call without an argument would block, return false immediately; otherwise, do the same thing as when called without arguments, and return true. When invoked with a timeout other than None, it will block for at most timeout seconds. If acquire does not complete successfully in that interval, return false. Return true otherwise. Nz.can't specify timeout for non-blocking acquireFrr8T)rUr`rarXrW)r+r:r;r=rYrrr r9ƒs$   zSemaphore.acquirec Cs.|j�|jd7_|jjƒWdQRXdS)z×Release a semaphore, incrementing the internal counter by one. When the counter is zero on entry and another thread is waiting for it to become larger than zero again, wake up that thread. r8N)r`rar^)r+rrr r?²szSemaphore.releasecCs |jƒdS)N)r?)r+r@rArBrrr rC½szSemaphore.__exit__)r8)TN) rIr2r3rJr,r9rKr?rCrrrr rqs   - c@s"eZdZdZddd„Zdd„ZdS) ra©Implements a bounded semaphore. A bounded semaphore checks to make sure its current value doesn't exceed its initial value. If it does, ValueError is raised. In most situations semaphores are used to guard resources with limited capacity. If the semaphore is released too many times it's a sign of a bug. If not given, value defaults to 1. Like regular semaphores, bounded semaphores manage a counter representing the number of release() calls minus the number of acquire() calls, plus an initial value. The acquire() method blocks if necessary until it can return without making the counter negative. If not given, value defaults to 1. r8cCstj||ƒ||_dS)N)rr,Ú_initial_value)r+rbrrr r,Òs zBoundedSemaphore.__init__c CsB|j�2|j|jkrtdƒ‚|jd7_|jjƒWdQRXdS)a6Release a semaphore, incrementing the internal counter by one. When the counter is zero on entry and another thread is waiting for it to become larger than zero again, wake up that thread. If the number of releases exceeds the number of acquires, raise a ValueError. z!Semaphore released too many timesr8N)r`rarcrUr^)r+rrr r?Ös  zBoundedSemaphore.releaseN)r8)rIr2r3rJr,r?rrrr rÁs c@sFeZdZdZdd„Zdd„Zdd„ZeZdd „Zd d „Z dd d„Z d S)rzòClass implementing event objects. Events manage a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. cCsttƒƒ|_d|_dS)NF)r rr`Ú_flag)r+rrr r,òs zEvent.__init__cCs|jjtƒƒdS)N)r`r,r)r+rrr Ú_reset_internal_locksöszEvent._reset_internal_lockscCs|jS)z5Return true if and only if the internal flag is true.)rd)r+rrr Úis_setúsz Event.is_setc Cs&|j�d|_|jjƒWdQRXdS)z·Set the internal flag to true. All threads waiting for it to become true are awakened. Threads that call wait() once the flag is true will not block at all. TN)r`rdr_)r+rrr Úsetsz Event.setc Cs|j� d|_WdQRXdS)zªReset the internal flag to false. Subsequently, threads calling wait() will block until set() is called to set the internal flag to true again. FN)r`rd)r+rrr Úclear sz Event.clearNc Cs,|j�|j}|s|jj|ƒ}|SQRXdS)aHBlock until the internal flag is true. If the internal flag is true on entry, return immediately. Otherwise, block until another thread calls set() to set the flag to true, or until the optional timeout occurs. When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). This method returns the internal flag on exit, so it will always return True except if a timeout is given and the operation times out. N)r`rdrW)r+r;Zsignaledrrr rWs  z Event.wait)N) rIr2r3rJr,rerfZisSetrgrhrWrrrr rçs  c@s€eZdZdZddd„Zddd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z e dd„ƒZe dd„ƒZe dd„ƒZdS)rzÑImplements a Barrier. Useful for synchronizing a fixed number of threads at known synchronization points. Threads block on 'wait()' and are simultaneously once they have all made that call. NcCs.ttƒƒ|_||_||_||_d|_d|_dS)aWCreate a barrier, initialised to 'parties' threads. 'action' is a callable which, when supplied, will be called by one of the threads after they have all entered the barrier and just prior to releasing them all. If a 'timeout' is provided, it is uses as the default for all subsequent 'wait()' calls. rN)r rr`Ú_actionÚ_timeoutÚ_partiesÚ_stater*)r+ÚpartiesÚactionr;rrr r,?s zBarrier.__init__cCs€|dkr|j}|j�b|jƒ|j}|jd7_z&|d|jkrL|jƒn |j|ƒ|S|jd8_|jƒXWdQRXdS)aNWait for the barrier. When the specified number of threads have started waiting, they are all simultaneously awoken. If an 'action' was provided for the barrier, one of the threads will have executed that callback prior to returning. Returns an individual index number from 0 to 'parties-1'. Nr8)rjr`Ú_enterr*rkÚ_releaseÚ_waitÚ_exit)r+r;Úindexrrr rWOs   z Barrier.waitcCs:x|jdkr|jjƒqW|jdkr(t‚|jdks6t‚dS)Nr8rrH)rHr8)rlr`rWrÚAssertionError)r+rrr roms   zBarrier._enterc Cs>y"|jr|jƒd|_|jjƒWn|jƒ‚YnXdS)Nr8)rirlr`r_Ú_break)r+rrr rpxszBarrier._releasecsBˆjj‡fdd„|ƒs"ˆjƒt‚ˆjdkr0t‚ˆjdks>t‚dS)Ncs ˆjdkS)Nr)rlr)r+rr Ú‡szBarrier._wait..rr8)r`r[rurrlrt)r+r;r)r+r rq†s  z Barrier._waitcCs(|jdkr$|jdkr$d|_|jjƒdS)Nrr8rH)rHr8)r*rlr`r_)r+rrr rr‘s  z Barrier._exitc CsT|j�D|jdkr6|jdkr$d|_q<|jdkrReturn the number of threads currently waiting at the barrier.r)rlr*)r+rrr Ú n_waitingÁs zBarrier.n_waitingcCs |jdkS)z0Return True if the barrier is in a broken state.rwrx)rl)r+rrr ÚbrokenÊszBarrier.broken)NN)N)rIr2r3rJr,rWrorprqrrryrzruÚpropertyrmr{r|rrrr r6s       c@s eZdZdS)rN)rIr2r3rrrr rÐsú Thread-%dcCs |tƒS)N)Ú_counter)Útemplaterrr Ú_newname×sr�c@seZdZdZdZejZdddfdfddœdd„Zdd„Z d d „Z d d „Z d d„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd3dd„Zd5dd „Zed!d"„ƒZejd#d"„ƒZed$d%„ƒZd&d'„ZeZed(d)„ƒZejd*d)„ƒZd+d,„Zd-d.„Zd/d0„Zd1d2„ZdS)6raA class that represents a thread of control. This class can be safely subclassed in a limited fashion. There are two ways to specify the activity: by passing a callable object to the constructor, or by overriding the run() method in a subclass. FN)ÚdaemoncCsŽ|dkstdƒ‚|dkri}||_t|p,tƒƒ|_||_||_|dk rN||_n tƒj |_d|_ d|_ t ƒ|_ d|_d|_tj|_tj|ƒdS)aKThis constructor should always be called with keyword arguments. Arguments are: *group* should be None; reserved for future extension when a ThreadGroup class is implemented. *target* is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called. *name* is the thread name. By default, a unique name is constructed of the form "Thread-N" where N is a small decimal number. *args* is the argument tuple for the target invocation. Defaults to (). *kwargs* is a dictionary of keyword arguments for the target invocation. Defaults to {}. If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread. Nz#group argument must be None for nowFT)rtÚ_targetÚstrr�Ú_nameÚ_argsÚ_kwargsÚ _daemonicr r‚Ú_identÚ _tstate_lockrÚ_startedÚ _is_stoppedÚ _initializedÚ_sysÚstderrÚ_stderrÚ _danglingÚadd)r+ÚgroupÚtargetr/r$r%r‚rrr r,õs" zThread.__init__cCs(|jjƒ|r|jƒn d|_d|_dS)NT)r‹reÚ_set_tstate_lockrŒrŠ)r+Úis_aliverrr re"s   zThread._reset_internal_lockscCsl|jstdƒ‚d}|jjƒr d}|jƒ|jr2d}|jr@|d7}|jdk rX|d|j7}d|jj |j |fS)Nz Thread.__init__() was not calledÚinitialZstartedZstoppedz daemonz %sz <%s(%s, %s)>) r�rtr‹rfr–rŒrˆr‰r1rIr…)r+Zstatusrrr r7.s  zThread.__repr__cCs„|jstdƒ‚|jjƒr tdƒ‚t�|t|<WdQRXyt|jfƒWn,tk rtt� t|=WdQRX‚YnX|jj ƒdS)a-Start the thread's activity. It must be called at most once per thread object. It arranges for the object's run() method to be invoked in a separate thread of control. This method will raise a RuntimeError if called more than once on the same thread object. zthread.__init__() not calledz threads can only be started onceN) r�r>r‹rfÚ_active_limbo_lockÚ_limboÚ_start_new_threadÚ _bootstrapÚ ExceptionrW)r+rrr Ústart<s  z Thread.startc Cs.z|jr|j|j|jŽWd|`|`|`XdS)aXMethod representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively. N)rƒr†r‡)r+rrr ÚrunUs z Thread.runc Cs2y |jƒWn |jr&tdkr&dS‚YnXdS)N)Ú_bootstrap_innerrˆrŽ)r+rrr r›fs  zThread._bootstrapcCs tƒ|_dS)N)rr‰)r+rrr Ú _set_identzszThread._set_identcCstƒ|_|jjƒdS)z” Set a lock object which will be released by the interpreter when the underlying thread state (see pystate.h) gets deleted. N)Ú _set_sentinelrŠr9)r+rrr r•}szThread._set_tstate_lockc2Csˆ�zT|jƒ|jƒ|jjƒt�|t|j<t|=WdQRXtrLt j tƒt rZt j t ƒzöy |j ƒWnätk r|YnÒt r¬t jdk r¬td|jtƒft jd�nœ|jdk �rH|jƒ\}}}zxtd|jd|jd�td|jd�x6|�r$td|jjj|j|jjjf|jd�|j}qðWtd||f|jd�Wd~~~XYnXWdXWdt� y ttƒ=Wn YnXWdQRXXdS)NzException in thread %s: %s)ÚfilezException in thread z2 (most likely raised during interpreter shutdown):z"Traceback (most recent call last):z File "%s", line %s, in %sz%s: %s)r r•r‹rgr˜r.r‰r™r!rŽrrrržÚ SystemExitr�Úprintr/Ú _format_excr�Ú _exc_infoÚtb_frameÚf_codeÚ co_filenameÚ tb_linenoÚco_nameÚtb_nextr)r+Úexc_typeÚ exc_valueZexc_tbrrr rŸ…sT         zThread._bootstrap_innercCs,|j}|dk r|jƒ st‚d|_d|_dS)NT)rŠr-rtrŒ)r+rPrrr Ú_stopÆs z Thread._stopcCsByt�ttƒ=WdQRXWn tk r<dtjkr8‚YnXdS)zARemove current thread from the dict of currently running threads.NZdummy_threading)r˜r.rr0rŽÚmodules)r+rrr Ú_deleteÝs  zThread._deletecCsZ|jstdƒ‚|jjƒs tdƒ‚|tƒkr2tdƒ‚|dkrD|jƒn|jt|dƒd�dS)aWait until the thread terminates. This blocks the calling thread until the thread whose join() method is called terminates -- either normally or through an unhandled exception or until the optional timeout occurs. When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call isAlive() after join() to decide whether a timeout happened -- if the thread is still alive, the join() call timed out. When the timeout argument is not present or None, the operation will block until the thread terminates. A thread can be join()ed many times. join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception. zThread.__init__() not calledz'cannot join thread before it is startedzcannot join current threadNr)r;)r�r>r‹rfr Ú_wait_for_tstate_lockÚmax)r+r;rrr Újoins   z Thread.joinTr8cCs:|j}|dkr|js6t‚n|j||ƒr6|jƒ|jƒdS)N)rŠrŒrtr9r?r¯)r+Úblockr;rPrrr r²&s   zThread._wait_for_tstate_lockcCs|jstdƒ‚|jS)z¸A string used for identification purposes only. It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor. zThread.__init__() not called)r�rtr…)r+rrr r/4sz Thread.namecCs|jstdƒ‚t|ƒ|_dS)NzThread.__init__() not called)r�rtr„r…)r+r/rrr r/?scCs|jstdƒ‚|jS)a4Thread identifier of this thread or None if it has not been started. This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited. zThread.__init__() not called)r�rtr‰)r+rrr ÚidentDs z Thread.identcCs6|jstdƒ‚|js |jjƒ r$dS|jdƒ|j S)zöReturn whether the thread is alive. This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads. zThread.__init__() not calledF)r�rtrŒr‹rfr²)r+rrr r–Ps  zThread.is_alivecCs|jstdƒ‚|jS)aÆA boolean value indicating whether this thread is a daemon thread. This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False. The entire Python program exits when no alive non-daemon threads are left. zThread.__init__() not called)r�rtrˆ)r+rrr r‚`s z Thread.daemoncCs*|jstdƒ‚|jjƒr tdƒ‚||_dS)NzThread.__init__() not calledz)cannot set daemon status of active thread)r�r>r‹rfrˆ)r+Údaemonicrrr r‚ps  cCs|jS)N)r‚)r+rrr ÚisDaemonxszThread.isDaemoncCs ||_dS)N)r‚)r+r·rrr Ú setDaemon{szThread.setDaemoncCs|jS)N)r/)r+rrr ÚgetName~szThread.getNamecCs ||_dS)N)r/)r+r/rrr ÚsetName�szThread.setName)NrH)TrH) rIr2r3rJr�rŽÚexc_infor¦r,rer7r�ržr›r r•rŸr¯r±r´r²r}r/Úsetterr¶r–ZisAliver‚r¸r¹rºr»rrrr râs8, A# &    c@s*eZdZdZd dd„Zdd„Zdd„ZdS) rzÓCall a function after a specified number of seconds: t = Timer(30.0, f, args=None, kwargs=None) t.start() t.cancel() # stop the timer's action if it's still waiting NcCsFtj|ƒ||_||_|dk r"|ng|_|dk r4|ni|_tƒ|_dS)N)rr,ÚintervalÚfunctionr$r%rÚfinished)r+r¾r¿r$r%rrr r,�s  zTimer.__init__cCs|jjƒdS)z)Stop the timer if it hasn't finished yet.N)rÀrg)r+rrr Úcancel—sz Timer.cancelcCs6|jj|jƒ|jjƒs(|j|j|jŽ|jjƒdS)N)rÀrWr¾rfr¿r$r%rg)r+rrr rž›s z Timer.run)NN)rIr2r3rJr,rÁržrrrr r†s c@seZdZdd„ZdS)Ú _MainThreadc CsHtj|ddd�|jƒ|jjƒ|jƒt�|t|j<WdQRXdS)NZ MainThreadF)r/r‚) rr,r•r‹rgr r˜r.r‰)r+rrr r,¦s  z_MainThread.__init__N)rIr2r3r,rrrr r¤srÂc@s.eZdZdd„Zdd„Zdd„Zd dd „ZdS) Ú _DummyThreadc CsDtj|tdƒdd�|jjƒ|jƒt�|t|j<WdQRXdS)NzDummy-%dT)r/r‚) rr,r�r‹rgr r˜r.r‰)r+rrr r,¹s  z_DummyThread.__init__cCsdS)Nr)r+rrr r¯Ász_DummyThread._stopcCs|j r|jjƒst‚dS)NT)rŒr‹rfrt)r+rrr r–Äsz_DummyThread.is_aliveNcCsds tdƒ‚dS)NFzcannot join a dummy thread)rt)r+r;rrr r´Èsz_DummyThread.join)N)rIr2r3r,r¯r–r´rrrr r÷srÃc Cs&y ttƒStk r tƒSXdS)zïReturn the current Thread object, corresponding to the caller's thread of control. If the caller's thread of control was not created through the threading module, a dummy thread object with limited functionality is returned. N)r.rr0rÃrrrr r Îs c Cs t�ttƒttƒSQRXdS)z’Return the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate(). N)r˜rQr.r™rrrr r ÜscCsttjƒƒttjƒƒS)N)Úlistr.Úvaluesr™rrrr Ú _enumerateèsrÆc Cs(t�ttjƒƒttjƒƒSQRXdS)zýReturn a list of all Thread objects currently alive. The list includes daemonic threads, dummy thread objects created by current_thread(), and the main thread. It excludes terminated threads and threads that have not yet been started. N)r˜rÄr.rÅr™rrrr r ìs)rcCsPtj}|dk st‚|jƒst‚|jƒtjƒtƒ}x|rJ|jƒtƒ}q6WdS)N)Ú _main_threadrŠrtr-r?r¯Ú_pickSomeNonDaemonThreadr´)Ztlockr@rrr Ú _shutdownÿs  rÉcCs(x"tƒD]}|j r|jƒr|SqWdS)N)r r‚r–)r@rrr rÈs rÈcCstS)z�Return the main thread object. In normal conditions, the main thread is the thread from which the Python interpreter was started. )rÇrrrr r s)Ú_local)rc Cs®tƒai}tƒ}|at�Œttƒƒ}|jtƒxF|D]>}||kr`|jdƒt ƒ}||_ |||<q4|jdƒ|j ƒq4Wt j ƒtj ƒtj|ƒttƒdks t‚WdQRXdS)NTFr8)r'r˜r rÇrgrÆÚupdater‘rerr‰r¯r™rhr.rQrt)Z new_activeZcurrentZthreadsZthreadr¶rrr Ú _after_fork(s&        rÌ)r~)KrJÚsysrŽÚ_threadZtimerrXÚ tracebackrr¥Ú _weakrefsetrÚ itertoolsrr\rr*Ú _collectionsrrNÚ ImportErrorÚ collectionsÚ__all__Ústart_new_threadršÚ allocate_lockr'r¡rÚerrorrrr"rMrrr!rrrr&r#r rrrrr>rÚ__next__rr�r˜r.r™r‘rrrÂrÃr Z currentThreadr Z activeCountrÆr rrÇrÉrÈr rÊrZ_threading_localrÌrrrr Ús�           q'P&O '