Package Ganga :: Package Utility :: Module threads
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Utility.threads

1 -def execInThread( target, args = (), kwargs = {}, timeout = None, 2 waitFlag = False, lock = ( None, None ), 3 callBackFunc = None ):
4 def _child( target, args, kwargs ): 5 try: 6 if lock[ 0 ]: 7 if lock[ 1 ] is None: 8 lock[ 0 ].acquire() 9 else: 10 lock[ 0 ].acquire( lock[ 1 ] ) 11 result = target( *args, **kwargs ) 12 finally: 13 if lock[ 0 ]: 14 lock[ 0 ].release() 15 if callBackFunc: 16 callBackFunc( result ) 17 return
18 19 if not callable( target ): 20 return False 21 22 import threading 23 childThread = threading.Thread( target = _child( target, args, kwargs) ) 24 childThread.start() 25 26 # ------------------------ 27 28 from util import GenericWrapper 29
30 -class SynchronisedObject( GenericWrapper ):
31 - def __init__( self, obj, ignore = (), lock = None ):
32 if lock is None: 33 import threading 34 lock = threading.RLock() 35 GenericWrapper.__init__( self, obj, lock.acquire, lock.release, ignore )
36