python::AsyncCallThread Namespace Reference


Classes

class  AsyncCallThread

Functions

def async_call
def timeout_call


Function Documentation

def python::AsyncCallThread::async_call (   callback,
  func,
  args,
  kwds 
)

Call func asynchronously in a separate thread. See AsyncCallThread class for details.

Definition at line 42 of file AsyncCallThread.py.

00042                                             :
00043     """Call func asynchronously in a separate thread. See AsyncCallThread class for details."""
00044     t = AsyncCallThread(callback,func,*args,**kwds)
00045     t.start()
00046     return t
00047 
00048 
def timeout_call(caller,func, timeout, *args, **kwds):

def python::AsyncCallThread::timeout_call (   caller,
  func,
  timeout,
  args,
  kwds 
)

Definition at line 49 of file AsyncCallThread.py.

00049                                                      :
00050     def callback(t):
00051         print 'completed'
00052 
00053     t = AsyncCallThread(callback,func,*args,**kwds)
00054     t.start()
00055     time.sleep(1)
00056     while time.time()-t.start_time < timeout:
00057         if t.stop_time:
00058             if t.exception:
00059                 raise t.exception
00060             else:
00061                 return t.result
00062 
00063         time.sleep(1)
00064 
00065     #  Extension to Kuba's code
00066 
00067     from GBSLogger    import GetLoggerThreshold, Log, logger 
00068     from GBSUtilities import RemoveChildProcesses
00069     from GBSTimeStamp import GBSTimeStamp
00070     
00071     Log(caller,logger.ERROR,"Timeout reached before asynchronous call ended ...")
00072     Log(caller,logger.ERROR,"...Attempting to delete child processes to unblock before raising timeout exception...")
00073     RemoveChildProcesses()    
00074     raise Exception('timeout!')
00075 


Generated on Fri Mar 5 09:25:41 2010 for gbs by  doxygen 1.4.7