def run_in_background(name, args, **kwargs):
 if is_running(name):
  wf().logger.info(u'Task `{0}` is already running'.format(name))
  return
 argcache = _arg_cache(name)
 with open(argcache, u'wb') as file_obj:
  pickle.dump({u'args': args, u'kwargs': kwargs}, file_obj)
  wf().logger.debug(u'Command arguments cached to `{0}`'.format(argcache))
 cmd = [u'/usr/bin/python', __file__, name]
 wf().logger.debug(u'Calling {0!r} ...'.format(cmd))
 retcode = subprocess.call(cmd)
 if retcode:
  wf().logger.error(u'Failed to call task in background')
 else:
  wf().logger.debug(u'Executing task `{0}` in background...'.format(name))
 return retcode

def run_in_background ( name , args , ** kwargs ) : if is_running ( name ) : wf ( ) . logger . info ( u'Task `{0}` is already running' . format ( name ) ) return argcache = _arg_cache ( name ) with open ( argcache , u'wb' ) as file_obj : pickle . dump ( { u'args' : args , u'kwargs' : kwargs } , file_obj ) wf ( ) . logger . debug ( u'Command arguments cached to `{0}`' . format ( argcache ) ) cmd = [ u'/usr/bin/python' , __file__ , name ] wf ( ) . logger . debug ( u'Calling {0!r} ...' . format ( cmd ) ) retcode = subprocess . call ( cmd ) if retcode : wf ( ) . logger . error ( u'Failed to call task in background' ) else : wf ( ) . logger . debug ( u'Executing task `{0}` in background...' . format ( name ) ) return retcode
pickle arguments to cache file .