Write return to all returners in multi_returner
507532
def returner(load):
    '''
    
    '''
    for returner_ in __opts__[CONFIG_KEY]:
        _mminion().returners['{0}.returner'.format(returner_)](load)
551027
def join(self, *args, **kwargs):
        
        super(ThreadReturn, self).join(*args, **kwargs)
        return self._return
277817
def _return_pub_multi(self, rets, ret_cmd='_return', timeout=60, sync=True):
        '''
        
        '''
        if not isinstance(rets, list):
            rets = [rets]
        jids = {}
        for ret in rets:
            jid = ret.get('jid', ret.get('__jid__'))
            fun = ret.get('fun', ret.get('__fun__'))
            if self.opts['multiprocessing']:
                fn_ = os.path.join(self.proc_dir, jid)
                if os.path.isfile(fn_):
                    try:
                        os.remove(fn_)
                    except (OSError, IOError):
                        # The file is gone already
                        pass
            log.info('Returning information for job: %s', jid)
            load = jids.setdefault(jid, {})
            if ret_cmd == '_syndic_return':
                if not load:
                    load.update({'id': self.opts['id'],
                                 'jid': jid,
                                 'fun': fun,
                                 'arg': ret.get('arg'),
                                 'tgt': ret.get('tgt'),
                                 'tgt_type': ret.get('tgt_type'),
                                 'load': ret.get('__load__'),
                                 'return': {}})
                if '__master_id__' in ret:
                    load['master_id'] = ret['__master_id__']
                for key, value in six.iteritems(ret):
                    if key.startswith('__'):
                        continue
                    load['return'][key] = value
            else:
                load.update({'id': self.opts['id']})
                for key, value in six.iteritems(ret):
                    load[key] = value

            if 'out' in ret:
                if isinstance(ret['out'], six.string_types):
                    load['out'] = ret['out']
                else:
                    log.error(
                        'Invalid outputter %s. This is likely a bug.',
                        ret['out']
                    )
            else:
                try:
                    oput = self.functions[fun].__outputter__
                except (KeyError, AttributeError, TypeError):
                    pass
                else:
                    if isinstance(oput, six.string_types):
                        load['out'] = oput
            if self.opts['cache_jobs']:
                # Local job cache has been enabled
                salt.utils.minion.cache_jobs(self.opts, load['jid'], ret)

        load = {'cmd': ret_cmd,
                'load': list(six.itervalues(jids))}

        def timeout_handler(*_):
            log.warning(
               'The minion failed to return the job information for job %s. '
               'This is often due to the master being shut down or '
               'overloaded. If the master is running, consider increasing '
               'the worker_threads value.', jid
            )
            return True

        if sync:
            try:
                ret_val = self._send_req_sync(load, timeout=timeout)
            except SaltReqTimeoutError:
                timeout_handler()
                return ''
        else:
            with tornado.stack_context.ExceptionStackContext(timeout_handler):
                ret_val = self._send_req_async(load, timeout=timeout, callback=lambda f: None)  # pylint: disable=unexpected-keyword-arg

        log.trace('ret_val = %s', ret_val)  # pylint: disable=no-member
        return ret_val
645814
def writelines(self, sequence):
        
        iterator = iter(sequence)

        def iterate(_=None):
            try:
                return self.write(next(iterator)).addCallback(iterate)
            except StopIteration:
                return
        return defer.maybeDeferred(iterate)
312152
protected void writeCombiner( TupleCombiner combiner)
    {
    writer_
      .element( COMBINE_TAG)
      .attribute( TUPLES_ATR, String.valueOf( combiner.getTupleSize()))
      .content( () ->
        {
        Arrays.stream( combiner.getIncluded())
          .sorted()
          .forEach( this::writeIncluded);
        
        Arrays.stream( combiner.getExcluded())
          .sorted()
          .forEach( this::writeExcluded);

        toStream( combiner.getOnceTuples()).forEach( this::writeOnceTuple);
        })
      .write();
    }
295671
function multi(list /*, ... */) {
		var mw = core.base();
		mw.targets = (isArray(list) ? list : Array.prototype.slice.call(arguments.length, 0));
		mw.enabled = true;
		mw.writeln = function (line) {
			if (mw.enabled) {
				for (var i = 0, ii = mw.targets.length; i < ii; i++) {
					mw.targets[i].writeln(line);
				}
			}
		};
		mw.toString = function () {
			return '<miniwrite-multi>';
		};
		return mw;
	}
172649
def _thread_multi_return(cls, minion_instance, opts, data):
        '''
        
        '''
        fn_ = os.path.join(minion_instance.proc_dir, data['jid'])

        if opts['multiprocessing'] and not salt.utils.platform.is_windows():
            # Shutdown the multiprocessing before daemonizing
            salt.log.setup.shutdown_multiprocessing_logging()

            salt.utils.process.daemonize_if(opts)

            # Reconfigure multiprocessing logging after daemonizing
            salt.log.setup.setup_multiprocessing_logging()

        salt.utils.process.appendproctitle('{0}._thread_multi_return {1}'.format(cls.__name__, data['jid']))

        sdata = {'pid': os.getpid()}
        sdata.update(data)
        log.info('Starting a new job with PID %s', sdata['pid'])
        with salt.utils.files.fopen(fn_, 'w+b') as fp_:
            fp_.write(minion_instance.serial.dumps(sdata))

        multifunc_ordered = opts.get('multifunc_ordered', False)
        num_funcs = len(data['fun'])
        if multifunc_ordered:
            ret = {
                'return': [None] * num_funcs,
                'retcode': [None] * num_funcs,
                'success': [False] * num_funcs
            }
        else:
            ret = {
                'return': {},
                'retcode': {},
                'success': {}
            }

        for ind in range(0, num_funcs):
            if not multifunc_ordered:
                ret['success'][data['fun'][ind]] = False
            try:
                minion_blackout_violation = False
                if minion_instance.connected and minion_instance.opts['pillar'].get('minion_blackout', False):
                    whitelist = minion_instance.opts['pillar'].get('minion_blackout_whitelist', [])
                    # this minion is blacked out. Only allow saltutil.refresh_pillar and the whitelist
                    if data['fun'][ind] != 'saltutil.refresh_pillar' and data['fun'][ind] not in whitelist:
                        minion_blackout_violation = True
                elif minion_instance.opts['grains'].get('minion_blackout', False):
                    whitelist = minion_instance.opts['grains'].get('minion_blackout_whitelist', [])
                    if data['fun'][ind] != 'saltutil.refresh_pillar' and data['fun'][ind] not in whitelist:
                        minion_blackout_violation = True
                if minion_blackout_violation:
                    raise SaltInvocationError('Minion in blackout mode. Set \'minion_blackout\' '
                                             'to False in pillar or grains to resume operations. Only '
                                             'saltutil.refresh_pillar allowed in blackout mode.')

                func = minion_instance.functions[data['fun'][ind]]

                args, kwargs = load_args_and_kwargs(
                    func,
                    data['arg'][ind],
                    data)
                minion_instance.functions.pack['__context__']['retcode'] = 0
                key = ind if multifunc_ordered else data['fun'][ind]
                ret['return'][key] = func(*args, **kwargs)
                retcode = minion_instance.functions.pack['__context__'].get(
                    'retcode',
                    0
                )
                if retcode == 0:
                    # No nonzero retcode in __context__ dunder. Check if return
                    # is a dictionary with a "result" or "success" key.
                    try:
                        func_result = all(ret['return'][key].get(x, True)
                                          for x in ('result', 'success'))
                    except Exception:
                        # return data is not a dict
                        func_result = True
                    if not func_result:
                        retcode = 1

                ret['retcode'][key] = retcode
                ret['success'][key] = retcode == 0
            except Exception as exc:
                trb = traceback.format_exc()
                log.warning('The minion function caused an exception: %s', exc)
                if multifunc_ordered:
                    ret['return'][ind] = trb
                else:
                    ret['return'][data['fun'][ind]] = trb
            ret['jid'] = data['jid']
            ret['fun'] = data['fun']
            ret['fun_args'] = data['arg']
        if 'metadata' in data:
            ret['metadata'] = data['metadata']
        if minion_instance.connected:
            minion_instance._return_pub(
                ret,
                timeout=minion_instance._return_retry_timer()
            )
        if data['ret']:
            if 'ret_config' in data:
                ret['ret_config'] = data['ret_config']
            if 'ret_kwargs' in data:
                ret['ret_kwargs'] = data['ret_kwargs']
            for returner in set(data['ret'].split(',')):
                ret['id'] = opts['id']
                try:
                    minion_instance.returners['{0}.returner'.format(
                        returner
                    )](ret)
                except Exception as exc:
                    log.error(
                        'The return failed for job %s: %s',
                        data['jid'], exc
                    )
950134
def write_remaining(self):
        
        if not self.results:
            return
        with db.execution_context():
            with db.atomic():
                Result.insert_many(self.results).execute()
        del self.results[:]
416394
def commitreturn(self, cursor, qstring, vals=()):
    ""
    cursor.execute(qstring, vals)
    return cursor.fetchall()[0]
1258786
private RValue[] packReturns(CallStack frame, Decl.Callable decl) {
		if (decl instanceof Decl.Property) {
			return new RValue[] { RValue.True };
		} else {
			Tuple<Decl.Variable> returns = decl.getReturns();
			RValue[] values = new RValue[returns.size()];
			for (int i = 0; i != values.length; ++i) {
				values[i] = frame.getLocal(returns.get(i).getName());
			}
			return values;
		}
	}
1123161
def handle_return(self, frame, return_value):
        """"""
        self.obj_cache[id(return_value)] = return_value
        self.extra_vars['__return__'] = return_value
        fun = frame.f_code.co_name
        log.info('Returning from %r with value: %r' % (fun, return_value))

        init = 'Echo|%s' % dump({
            'for': '__return__',
            'val': self.safe_better_repr(return_value)
        })
        self.interaction(
            frame,
            init=init,
            exception_description='Returning from %s with value %s' %
            (fun, return_value)
        )
757639
def call_many(self, callback, args):
        """"""
        if isinstance(callback, str):
            callback = getattr(self, callback)
        f = None
        for arg in args:
            f = callback(*arg)
        return f
592987
function getReturns() {
  var tag = getTag(this, 'returns'),
      desc = _.toString(_.get(tag, 'description')),
      type = _.toString(_.get(tag, 'type.name')) || '*';

  return tag ? [type, desc] : [];
}
339508
def _syndic_return(self, load):
        '''
        
        '''
        # Verify the load
        if any(key not in load for key in ('return', 'jid', 'id')):
            return None
        # if we have a load, save it
        if 'load' in load:
            fstr = '{0}.save_load'.format(self.opts['master_job_cache'])
            self.mminion.returners[fstr](load['jid'], load['load'])

        # Format individual return loads
        for key, item in six.iteritems(load['return']):
            ret = {'jid': load['jid'],
                   'id': key,
                   'return': item}
            if 'out' in load:
                ret['out'] = load['out']
            self._return(ret)
1041745
def _rebuffer(self):
        
        # collect a stride worth of results(result lists) or exceptions
        results = []
        exceptions = []
        for i in xrange(self.stride):
            try:
                results.append(self.iterable.next())
                exceptions.append(False)
            except Exception, excp:
                results.append(excp)
                exceptions.append(True)
        # un-roll the result lists
        res_exc = []
        for rep in xrange(self.n):
            flat_results = []
            for i in xrange(self.stride):
                result_list, exception = results[i], exceptions[i]
                if not exception:
                    flat_results.append(result_list[rep])
                else:
                    flat_results.append(result_list)
            res_exc.append((flat_results, exceptions))
        # make an iterator (like repeat)
        self._repeat_buffer = iter(res_exc)
716699
def do_retval(self, arg):
        
        locals = self.get_locals(self.curframe)
        if '__return__' in locals:
            self.message(bdb.safe_repr(locals['__return__']))
        else:
            self.error('Not yet returned!')
743093
def return_type(self):
        
        returns = self.returns
        if returns:
            return [r.type for r in returns]
        return None