o ¯bÿ ã@sÀdZddlmZGdd„dƒZdd„Zde_dd „Zd d „Zd d „Zdd„Z ddd„Z e ƒZ dd„Z dd„Zdd„ZdadadadazddlZWn eySdZYnweZe dƒgd¢ZdS)zT A module to provide some very basic threading primitives, such as synchronization. é©Úwrapsc@seZdZdZdd„ZdS)Ú DummyLockzF Hack to allow locks to be unpickled on an unthreaded system. cCótdfS©N©©Ú unpickle_lock©Úselfrrú;/usr/lib/python3/dist-packages/twisted/python/threadable.pyÚ __reduce__ózDummyLock.__reduce__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrr rs rcCstdurtƒStƒS©N)ÚthreadingmoduleÚXLockrrrrr r sr TcCs>d|jvrt ¡d|jvrtƒ|jd<t ¡|j ¡dS)NÚ_threadable_lock)Ú__dict__Ú_synchLockCreatorÚacquirerÚreleaserr rrr Ú _synchPre!s   rcCs|j ¡dSr)rrr rrr Ú _synchPost*srcstˆƒ‡fdd„ƒ}|S)Ncs4t|ƒzˆ|g|¢Ri|¤ŽWt|ƒSt|ƒwr)rr)r ÚargsÚkwargs©Úfunctionrr Úsync/sz_sync..syncr)Úklassr r!rrr Ú_sync.sr#cGsBtdur|D]}|jD]}t||j|ƒ}t|||ƒq qdSdS)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)rÚ synchronizedr#rÚsetattr)Úklassesr"Ú methodNamer!rrr Ú synchronize:s þþr(écCsN|rtstdurdaGdd„dtjƒatƒadStdƒ‚dStr$tdƒ‚ dS)zbInitialize threading. Don't bother calling this. If it needs to happen, it will happen. NTc@seZdZdd„ZdS)rcSrrrr rrr r VrzXLock.__reduce__N)rrrr rrrr rUs rz:Cannot initialize threading, platform lacks thread supportzCannot uninitialize threads)ÚthreadedrÚ_RLockrrÚ RuntimeError)Ú with_threadsrrr ÚinitIs ÿör.cCstdurtSt ¡jSr)rÚ_dummyIDÚcurrent_threadÚidentrrrr Ú getThreadIDhs r2cCs ttƒkS)zCAre we in the thread responsible for I/O requests (the event loop)?)ÚioThreadr2rrrr Ú isInIOThreadns r4cCs tƒadS)z8Mark the current thread as responsible for I/O requests.N)r2r3rrrr ÚregisterAsIOThreadss r5NF)r4r5r2r)r))rÚ functoolsrrr Ú__safe_for_unpickling__rrr#r(r.Úobjectr/r2r4r5r3r*rrÚ threadingÚ_threadingmoduleÚ ImportErrorrÚ__all__rrrr Ús4      ÿ