def warnIfDispersyThread(func):
 def invoke_func(*args, **kwargs):
  from twisted.python.threadable import isInIOThread
  from traceback import print_stack
  if isInIOThread():
   import inspect
   caller = inspect.stack()[1]
   callerstr = ('%s %s:%s' % (caller[3], caller[1], caller[2]))
   from time import time
   logger.error('%d CANNOT BE ON DISPERSYTHREAD %s %s:%s called by %s', long(time()), func.__name__, func.func_code.co_filename, func.func_code.co_firstlineno, callerstr)
   print_stack()
  return func(*args, **kwargs)
 invoke_func.__name__ = func.__name__
 return invoke_func

def warnIfDispersyThread ( func ) : def invoke_func ( * args , ** kwargs ) : from twisted . python . threadable import isInIOThread from traceback import print_stack if isInIOThread ( ) : import inspect caller = inspect . stack ( ) [ 1 ] callerstr = ( '%s %s:%s' % ( caller [ 3 ] , caller [ 1 ] , caller [ 2 ] ) ) from time import time logger . error ( '%d CANNOT BE ON DISPERSYTHREAD %s %s:%s called by %s' , long ( time ( ) ) , func . __name__ , func . func_code . co_filename , func . func_code . co_firstlineno , callerstr ) print_stack ( ) return func ( * args , ** kwargs ) invoke_func . __name__ = func . __name__ return invoke_func
wed rather not be on the dispersy thread .