def deferred(timeout=None):
 (reactor, reactor_thread) = threaded_reactor()
 if (reactor is None):
  raise ImportError('twisted is not available or could not be imported')
 try:
  ((timeout is None) or (timeout + 0))
 except TypeError:
  raise TypeError("'timeout' argument must be a number or None")
 def decorate(func):
  def wrapper(*args, **kargs):
   q = Queue()
   def callback(value):
    q.put(None)
   def errback(failure):
    try:
     failure.raiseException()
    except:
     q.put(sys.exc_info())
   def g():
    try:
     d = func(*args, **kargs)
     try:
      d.addCallbacks(callback, errback)
     except AttributeError:
      raise TypeError('you must return a twisted Deferred from your test case!')
    except:
     q.put(sys.exc_info())
   reactor.callFromThread(g)
   try:
    error = q.get(timeout=timeout)
   except Empty:
    raise TimeExpired(('timeout expired before end of test (%f s.)' % timeout))
   if (error is not None):
    (exc_type, exc_value, tb) = error
    raise exc_type, exc_value, tb
  wrapper = make_decorator(func)(wrapper)
  return wrapper
 return decorate

def deferred ( timeout = None ) : ( reactor , reactor_thread ) = threaded_reactor ( ) if ( reactor is None ) : raise ImportError ( 'twisted is not available or could not be imported' ) try : ( ( timeout is None ) or ( timeout + 0 ) ) except TypeError : raise TypeError ( "'timeout' argument must be a number or None" ) def decorate ( func ) : def wrapper ( * args , ** kargs ) : q = Queue ( ) def callback ( value ) : q . put ( None ) def errback ( failure ) : try : failure . raiseException ( ) except : q . put ( sys . exc_info ( ) ) def g ( ) : try : d = func ( * args , ** kargs ) try : d . addCallbacks ( callback , errback ) except AttributeError : raise TypeError ( 'you must return a twisted Deferred from your test case!' ) except : q . put ( sys . exc_info ( ) ) reactor . callFromThread ( g ) try : error = q . get ( timeout = timeout ) except Empty : raise TimeExpired ( ( 'timeout expired before end of test (%f s.)' % timeout ) ) if ( error is not None ) : ( exc_type , exc_value , tb ) = error raise exc_type , exc_value , tb wrapper = make_decorator ( func ) ( wrapper ) return wrapper return decorate
indicate a column-based mapped attribute that by default will not load unless accessed .