def shared_task(*args, **kwargs):
 def create_shared_task(**options):
  def __inner(fun):
   name = options.get(u'name')
   _state.connect_on_app_finalize((lambda app: app._task_from_fun(fun, **options)))
   for app in _state._get_active_apps():
    if app.finalized:
     with app._finalize_mutex:
      app._task_from_fun(fun, **options)
   def task_by_cons():
    app = _state.get_current_app()
    return app.tasks[(name or app.gen_task_name(fun.__name__, fun.__module__))]
   return Proxy(task_by_cons)
  return __inner
 if ((len(args) == 1) and callable(args[0])):
  return create_shared_task(**kwargs)(args[0])
 return create_shared_task(*args, **kwargs)

def shared_task ( * args , ** kwargs ) : def create_shared_task ( ** options ) : def __inner ( fun ) : name = options . get ( u'name' ) _state . connect_on_app_finalize ( ( lambda app : app . _task_from_fun ( fun , ** options ) ) ) for app in _state . _get_active_apps ( ) : if app . finalized : with app . _finalize_mutex : app . _task_from_fun ( fun , ** options ) def task_by_cons ( ) : app = _state . get_current_app ( ) return app . tasks [ ( name or app . gen_task_name ( fun . __name__ , fun . __module__ ) ) ] return Proxy ( task_by_cons ) return __inner if ( ( len ( args ) == 1 ) and callable ( args [ 0 ] ) ) : return create_shared_task ( ** kwargs ) ( args [ 0 ] ) return create_shared_task ( * args , ** kwargs )
create shared task .