Return Deferred that fires with a list of (priority, MX domain) tuples for
    a given domain.
192879
def _mx(domain):
    
    def got_records(result):
        return sorted(
            [(int(record.payload.preference), str(record.payload.name))
             for record in result[0]])
    d = lookupMailExchange(domain)
    d.addCallback(got_records)
    return d
722003
def list(self, domain=None):
        """"""
        # pylint: disable=arguments-differ
        if domain:
            return self._list(domain)
        url = "{base}".format(
            base="domains"
        )
        domains = self.core.get(url)
        res = []
        for dom in domains:
            domain_uuid = dom.get('identifier')
            url = "{base}".format(
                base=self.local_base_url
            )
            param = {
                'domainUuid': domain_uuid
            }
            encode = urllib.urlencode(param)
            if encode:
                url += "?"
                url += encode
            res += self.core.list(url)
        return res
56607
def list(domain=nil)
      if domain
        @mailgun.response = Mailgun::Base.fire(:get, @mailgun.api_url + "/domains/#{domain}")
      else
        @mailgun.response = Mailgun::Base.fire(:get, @mailgun.api_url + "/domains")["items"] || []
      end
    end
847997
def pre_dispatch(self):
        
        middleware = sort_by_priority(self)
        return tuple(m.pre_dispatch for m in middleware if hasattr(m, 'pre_dispatch'))
1275865
def proxy(self):
        """"""
        d = Deferred(self.loop)
        self._proxy_deferreds.append(d)

        if self._proxy:
            d.callback(self._proxy)

        return d
173727
def +@
      response = Fiber.yield(Delayer::Deferred::Request::Await.new(self))
      if response.ok?
        response.value
      else
        Delayer::Deferred.fail(response.value)
      end
    end
766665
private <T> DeferredAction<M> deferAction(
      final M metadata, final Supplier<? extends CompletionStage<T>> action,
      final CompletableFuture<T> future
  ) {
    return new DeferredAction<>(metadata, () -> {
      final CompletionStage<? extends T> resultFuture;

      try {
        resultFuture = action.get();
      } catch (final Exception e) {
        future.completeExceptionally(e);
        markProcessed(metadata);
        return;
      }

      resultFuture.handleAsync((result, e) -> {
        if (e != null) {
          future.completeExceptionally(e);
        } else {
          future.complete(result);
        }

        markProcessed(metadata);
        return null;
      }, executor);
    });
  }
948390
def item_from_event(self, domain_event_or_events):
        
        # Convert the domain event(s) to sequenced item(s).
        if isinstance(domain_event_or_events, (list, tuple)):
            return [self.item_from_event(e) for e in domain_event_or_events]
        else:
            return self.mapper.item_from_event(domain_event_or_events)
192854
def list_subdomains(self, domain, limit=None, offset=None):
        
        return domain.list_subdomains(limit=limit, offset=offset)
250487
def del_cached_domain(domains):
    '''
    
    '''
    cache = salt.cache.Cache(__opts__, syspaths.CACHE_DIR)
    if isinstance(domains, six.string_types):
        domains = domains.split(',')
    if not isinstance(domains, list):
        raise CommandExecutionError(
            'You must pass in either a string containing one or more domains '
            'separated by commas, or a list of single domain strings'
        )
    success = []
    failed = []
    for domain in domains:
        try:
            cache.flush('venafi/domains', domain)
            success.append(domain)
        except CommandExecutionError:
            failed.append(domain)
    return {'Succeeded': success, 'Failed': failed}
110940
function chain(promise,
               onResolve = idResolveHandler,
               onReject = idRejectHandler) {
  var deferred = getDeferred(promise.constructor);
  switch (promise.status_) {
    case undefined:
      throw TypeError;
    case 0:
      promise.onResolve_.push(onResolve, deferred);
      promise.onReject_.push(onReject, deferred);
      break;
    case +1:
      promiseEnqueue(promise.value_, [onResolve, deferred]);
      break;
    case -1:
      promiseEnqueue(promise.value_, [onReject, deferred]);
      break;
  }
  return deferred.promise;
}
159793
function(deferred) {
			nextql
				.execute({
					RandomDie: {
						getDie: {
							$params: { numSides: 6 },
							rollOnce: 1,
							roll: {
								$params: { numRolls: 3 }
							}
						}
					}
				})
				.then(() => deferred.resolve());
		}
1216538
def _domain_check(domain, domain_list, resolve):
    
    if domain in domain_list:
        return True
    if resolve:
        for exchange in _get_mx_exchanges(domain):
            for value in domain_list:
                if exchange.endswith(value):
                    return True
    return False
442025
def after(self):
        

        d = Deferred()
        self._after_deferreds.append(d)
        return d.chain
1047780
def runDeferred(self, deferred):
        
        for handler, scope, offset in deferred:
            self.scopeStack = scope
            self.offset = offset
            handler()
274410
function execList(options) {
  const deferred = Q.defer();

  const json = options.json !== false;
  const offline = options.offline !== false;
  const cwd = options.cwd || process.cwd();
  const config = {json, offline, cwd};

  bower.commands.list(undefined, config)
      .on('end', (conf) => {
        deferred.resolve(flatten(conf));
      })
      .on('error', (error) => {
        deferred.reject(error);
      });

  return deferred.promise;
}
1176406
def waitForDeferred(d, result=None):
    """"""
    from twisted.internet import reactor
    assert reactor.greenlet != getcurrent(), "can't invoke this in the reactor greenlet"
    if result is None:
        result = AsyncResult()

    def cb(res):
        if isinstance(res, defer.Deferred):
            waitForDeferred(res, result)
        else:
            result.set(res)

    def eb(res):
        result.set_exception(res)

    d.addCallbacks(cb, eb)
    try:
        return result.get()
    except failure.Failure, ex:
        ex.raiseException()