Triggers the given org task to be run for all active orgs
    :param task_name: the full task name, e.g. 'myproj.myapp.tasks.do_stuff'
    :param queue: the name of the queue to send org sub-tasks to
549438
def trigger_org_task(task_name, queue="celery"):
    
    active_orgs = apps.get_model("orgs", "Org").objects.filter(is_active=True)
    for org in active_orgs:
        sig = signature(task_name, args=[org.pk])
        sig.apply_async(queue=queue)

    logger.info("Requested task '%s' for %d active orgs" % (task_name, len(active_orgs)))
1183035
def _queue_task(self, host, task, task_vars, play_context):
        
        ansible_mitogen.loaders.module_loader.find_plugin(
            name=task.action,
            mod_type='',
        )
        ansible_mitogen.loaders.connection_loader.get(
            name=play_context.connection,
            class_only=True,
        )
        ansible_mitogen.loaders.action_loader.get(
            name=task.action,
            class_only=True,
        )

        return super(StrategyMixin, self)._queue_task(
            host=host,
            task=task,
            task_vars=task_vars,
            play_context=play_context,
        )
122635
def task(name=None, t=INFO, *args, **kwargs):
    

    def c_run(name, f, t, args, kwargs):
        def run(*largs, **lkwargs):
            thread = __get_current_thread()
            old_name = __THREAD_PARAMS[thread][__THREAD_PARAMS_FNAME_KEY]
            __THREAD_PARAMS[thread][__THREAD_PARAMS_FNAME_KEY] = name

            r = log(name, f, t, largs, lkwargs, *args, **kwargs)

            __THREAD_PARAMS[thread][__THREAD_PARAMS_FNAME_KEY] = old_name
            return r

        return run

    if callable(name):
        f = name
        name = f.__name__

        return c_run(name, f, t, args, kwargs)

    if name == None:
        def wrapped(f):
            name = f.__name__
            return c_run(name, f, t, args, kwargs)

        return wrapped
    else:
        return lambda f: c_run(name, f, t, args, kwargs)
744639
def queue_actions(self, source, actions, event_args=None):
		
		source.event_args = event_args
		ret = self.trigger_actions(source, actions)
		source.event_args = None
		return ret
702228
def run(self, target, callback = None, name = None, complete = None, *args, **kargs):
        
        self.count_lock.acquire()
        if not self.workers:
            self.count_lock.release()
            self.add(name = name)
        else:
            self.count_lock.release()
        self.tasks.put((target, callback, name, complete, args, kargs))
925303
def pop(self, queue_name):
        
        task_id = self.conn.lpop(queue_name)
        data = self.conn.get(task_id)
        self.conn.delete(task_id)
        return data
934121
def invoke_task(task_string) # :nodoc:
      name, args = parse_task_string(task_string)
      t = self[name]
      t.invoke(*args)
    end
179470
def find_task_group(name)
      @task_groups[name].tap do |block|
        raise Exceptions::TaskGroupNotFound.new(name) unless block
      end
    end
910102
def task(self, name_or_class: Any) -> Task:
        ''''''

        if name_or_class in self.all_tasks:
            return self.all_tasks[name_or_class]

        try:
            return self.all_tasks.get(name_or_class.__class__.__name__, None)

        except AttributeError:
            return None
1059430
def org_task(task_key, lock_timeout=None):
    

    def _org_task(task_func):
        def _decorator(org_id):
            org = apps.get_model("orgs", "Org").objects.get(pk=org_id)
            maybe_run_for_org(org, task_func, task_key, lock_timeout)

        return shared_task(wraps(task_func)(_decorator))

    return _org_task
1082116
async def insert(self, task: Task) -> None:
        ''''''

        if not isinstance(task, Task):
            task = task()

        if task.name not in self.all_tasks:
            task.tasky = self
            self.all_tasks[task.name] = task

            await task.init()

        elif task != self.all_tasks[task.name]:
            raise Exception('Duplicate task %s' % task.name)

        if task.enabled:
            task.task = asyncio.ensure_future(self.start_task(task))
            self.running_tasks.add(task)
        else:
            task.task = None

        return task
545699
def queue(self, *args, **kwargs):
        
        self.scraper.task_manager.put(self, args, kwargs)
        return self
635751
def add_task(self, name=None, desc=None):
        
        # A name is required to create a task
        for k in self.get_tasks():
            if name in keys_of(k):
                raise ValueError('Task already exists')

        if name is not None:
            # desc can be None, so we can just append whatever we have
            self.grindstone['tasks'].append( {name: desc} )
        else:
            # Raising errors is good, and makes tests easy.
            raise ValueError('Tasks `name` cannot be None')
920906
def process_queue(queue=None, **kwargs):
    
    while True:
        item = queue.get()
        if item is None:
            queue.task_done()
            logger.info(f"{queue}: exiting process queue.")
            break
        filename = os.path.basename(item)
        try:
            queue.next_task(item, **kwargs)
        except Exception as e:
            queue.task_done()
            logger.warn(f"{queue}: item={filename}. {e}\n")
            logger.exception(e)
            sys.stdout.write(
                style.ERROR(
                    f"{queue}. item={filename}. {e}. Exception has been logged.\n"
                )
            )
            sys.stdout.flush()
            break
        else:
            logger.info(f"{queue}: Successfully processed {filename}.\n")
        queue.task_done()
819862
def add_task_status(self, name, **attrs):
        
        return TaskStatuses(self.requester).create(self.id, name, **attrs)
868753
def push_to_thread_queue(context)
      thread_name = context.respond_to?(:thread_name) ? context.thread_name : ::RightScale::AgentConfig.default_thread_name
      queue = nil
      @mutex.synchronize do
        queue = @thread_name_to_queue[thread_name]
        unless queue
          # continuation for when thread-named queue is finally closed.
          queue = create_thread_queue(thread_name) { push(THREAD_QUEUE_CLOSED_BUNDLE) }
          @thread_name_to_queue[thread_name] = queue
        end
      end

      # push context to selected thread queue
      queue.push(context)

      # always (re)activate in case an individual thread queue died unexpectedly.
      # has no effect if already active.
      queue.activate
      true
    end
665656
def task_add(self, subsystem, name, pid):
        

        args = {
            'subsystem': subsystem,
            'name': name,
            'pid': pid,
        }

        self._task_chk.check(args)
        return self._client.json('cgroup.task-add', args)