U  W[á ã@sÔdZddlmZmZddlmZGdd„deƒZdd„Zde_ d d „Z d d „Z d d„Z dd„Z ddd„ZeƒZdd„Zdd„Zdd„Zdadadadaz ddlZWnek rºdZYn XedƒddddgZdS)zT A module to provide some very basic threading primitives, such as synchronization. é)ÚdivisionÚabsolute_import©Úwrapsc@seZdZdZdd„ZdS)Ú DummyLockzF Hack to allow locks to be unpickled on an unthreaded system. cCstdfS©N©©Ú unpickle_lock©Úselfrrú;/usr/lib/python3/dist-packages/twisted/python/threadable.pyÚ __reduce__szDummyLock.__reduce__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrr rsrcCstdk rtƒStƒSdS©N)ÚthreadingmoduleÚXLockrrrrr r sr TcCs>d|jkr0t ¡d|jkr(tƒ|jd<t ¡|j ¡dS)NÚ_threadable_lock)Ú__dict__Ú_synchLockCreatorÚacquirerÚreleaserr rrr Ú _synchPre!s    rcCs|j ¡dSr)rrr rrr Ú _synchPost+srcstˆƒ‡fdd„ƒ}|S)Ncs,t|ƒzˆ|f|ž|ŽW¢St|ƒXdSr)rr)r ÚargsÚkwargs©Úfunctionrr Úsync1sz_sync..syncr)Úklassr r!rrr Ú_sync0sr#cGs>tdk r:|D],}|jD] }t||j|ƒ}t|||ƒqq dS)a& Make all methods listed in each class' synchronized attribute synchronized. The synchronized attribute should be a list of strings, consisting of the names of methods that must be synchronized. If we are running in threaded mode these methods will be wrapped with a lock. N)rZ synchronizedr#rÚsetattr)Zklassesr"Z methodNamer!rrr Ú synchronize<s  r%écCsL|r:tsHtdk r0daGdd„dtjtƒatƒaqHtdƒ‚ntrHtdƒ‚ndS)zbInitialize threading. Don't bother calling this. If it needs to happen, it will happen. NTc@seZdZdd„ZdS)rcSstdfSrr r rrr rYszXLock.__reduce__N)rrrrrrrr rXsrz:Cannot initialize threading, platform lacks thread supportzCannot uninitialize threads)ÚthreadedrZ_RLockÚobjectrrÚ RuntimeError)Z with_threadsrrr ÚinitLs  r*cCstdkr tSt ¡jSr)rÚ_dummyIDZ currentThreadZidentrrrr Ú getThreadIDhsr,cCs ttƒkS)zHAre we in the thread responsible for I/O requests (the event loop)? )ÚioThreadr,rrrr Ú isInIOThreadosr.cCs tƒadS)z=Mark the current thread as responsible for I/O requests. N)r,r-rrrr ÚregisterAsIOThreadvsr/NFr)r&)rZ __future__rrÚ functoolsrr(rr Z__safe_for_unpickling__rrr#r%r*r+r,r.r/r-r'rrZ threadingrÚ ImportErrorÚ__all__rrrr Ús0