o nnh$ @sUdZddlmZddlmZddlZddlZddlZddl Z ddl Z ddl Z e j de jde jfdZGddde jZdd d Ze ZiZd ed<ejdddZdS)zPython threading tools.) annotationsN TCallable.)boundcs6eZdZdZd fdd Zddd Zdd d ZZS) WrappedThreadz.wrapper) threadingLock functoolswraps)r%r*rr(rmutex3sr/zdict[str, threading.Lock] __named_locksnamestrc.Iterator[bool]ccs~tt|}rd}n d}t}t|<Wdn1s"wY| |VWddS1s8wYdS)z Context manager that provides named locks using threading.Lock instances. Once named lock instances are created they are not deleted. Returns True if this is the first instance of the named lock, otherwise False. FTN) __named_lockr0rr+r,)r1 lock_instancefirstrrr named_lockDs"r7)r%rrr)r1r2rr3)r# __future__rcollections.abcabcc contextlibr-rr+r typingtTypeVarCallableAnyrThreadrr/r,r4r0__annotations__contextmanagerr7rrrrs    #