returns a Deferred that fires once we've set this object up to
        track the protocol. Fails if we already have a protocol.
182943
def attach_protocol(self, proto):
        
        if self._protocol is not None:
            raise RuntimeError("Already have a protocol.")
        # make sure we have nothing in self.unsaved
        self.save()
        self.__dict__['_protocol'] = proto

        # FIXME some of this is duplicated from ctor
        del self.__dict__['_accept_all_']
        self.__dict__['post_bootstrap'] = defer.Deferred()
        if proto.post_bootstrap:
            proto.post_bootstrap.addCallback(self.bootstrap)
        return self.__dict__['post_bootstrap']
791455
function(success, error) {
                    // If this model is new, don't make an AJAX call.
                    // Instead, we have to construct the Deferred ourselves and return it.
                    if (this.isNew()) {
                        var self = this;
                        var def = can.Deferred();
                        def.then(success, error);

                        return def.done(function(data) {
                            self.destroyed(data);
                        }).resolve(self);
                    }

                    // If it isn't new, though, go ahead and make a request.
                    return makeRequest(this, 'destroy', success, error, 'destroyed');
                }
47473
private Deferred<Object> resolveUIDs() {
    
    class TagsCB implements Callback<Object, ArrayList<Object>> {
      @Override
      public Object call(final ArrayList<Object> ignored) throws Exception {
        rowkey_regex = getRowKeyRegex();
        return null;
      }
    }
    
    class PairResolution implements Callback<Object, ArrayList<byte[]>> {
      @Override
      public Object call(final ArrayList<byte[]> tags) throws Exception {
        if (tags.size() < 2) {
          throw new IllegalArgumentException("Somehow we received an array "
              + "that wasn't two bytes in size! " + tags);
        }
        pairs.add(new ByteArrayPair(tags.get(0), tags.get(1)));
        return Deferred.fromResult(null);
      }
    }
    
    class TagResolution implements Callback<Deferred<Object>, Object> {
      @Override
      public Deferred<Object> call(final Object unused) throws Exception {
        if (query.getTags() == null || query.getTags().isEmpty()) {
          return Deferred.fromResult(null);
        }
        
        pairs = Collections.synchronizedList(
            new ArrayList<ByteArrayPair>(query.getTags().size()));
        final ArrayList<Deferred<Object>> deferreds = 
            new ArrayList<Deferred<Object>>(pairs.size());
        
        for (final Pair<String, String> tags : query.getTags()) {
          final ArrayList<Deferred<byte[]>> deferred_tags = 
              new ArrayList<Deferred<byte[]>>(2);
          if (tags.getKey() != null && !tags.getKey().equals("*")) {
            deferred_tags.add(tsdb.getUIDAsync(UniqueIdType.TAGK, tags.getKey()));
          } else {
            deferred_tags.add(Deferred.<byte[]>fromResult(null));
          }
          if (tags.getValue() != null && !tags.getValue().equals("*")) {
            deferred_tags.add(tsdb.getUIDAsync(UniqueIdType.TAGV, tags.getValue()));
          } else {
            deferred_tags.add(Deferred.<byte[]>fromResult(null));
          }
          deferreds.add(Deferred.groupInOrder(deferred_tags)
              .addCallback(new PairResolution()));
        }
        return Deferred.group(deferreds).addCallback(new TagsCB());
      }
    }
    
    class MetricCB implements Callback<Deferred<Object>, byte[]> {
      @Override
      public Deferred<Object> call(final byte[] uid) throws Exception {
        metric_uid = uid;
        LOG.debug("Found UID (" + UniqueId.uidToString(metric_uid) + 
            ") for metric (" + query.getMetric() + ")");
        return new TagResolution().call(null);
      }
    }
    
    if (query.getMetric() != null && !query.getMetric().isEmpty() && 
        !query.getMetric().equals("*")) {
      return tsdb.getUIDAsync(UniqueIdType.METRIC, query.getMetric())
          .addCallbackDeferring(new MetricCB());
    } else {
      try {
        return new TagResolution().call(null);
      } catch (Exception e) {
        return Deferred.fromError(e);
      } 
    }
  }
352569
function (cb) {
            if (cb) {
                if (isPromise(cb)) {
                    cb = cb.callback;
                }
                if (this.__fired && this.__results) {
                    this.__callNextTick(cb, this.__results);
                } else {
                    this.__cbs.push(cb);
                }
            }
            return this;
        }
523620
@Weight(Weight.Unit.NORMAL)
  public static Deferred defer(@Nonnull final Deferred deferred) {
    REGISTRY.get().add(assertNotNull(deferred));
    return deferred;
  }
965782
def _connect_deferred(self, deferred):
        
        self._deferred = deferred

        # Because we use __del__, we need to make sure there are no cycles
        # involving this object, which is why we use a weakref:
        def put(result, eventual=weakref.ref(self)):
            eventual = eventual()
            if eventual:
                eventual._set_result(result)
            else:
                err(result, "Unhandled error in EventualResult")

        deferred.addBoth(put)
1192355
function() {
                        var args = Array.prototype.slice.call(arguments, 0);
                        deferredObject.reject.apply(null, ctxArgs.concat(args));
                    }
1171603
def send_deferred(self, auth):
        """"""
        if self.deferred.has_requests(auth):
            method_arg_pairs = self.deferred.get_method_args_pairs(auth)
            calls = self._composeCalls(method_arg_pairs)
            # should this call be made with no timeout? (e.g. is there a
            # wait())
            notimeout = self.deferred.get_notimeout(auth)
            try:
                r = self._callJsonRPC(auth, calls, returnreq=True, notimeout=notimeout)
            finally:
                # remove deferred calls
                self.deferred.reset(auth)
            return r
        raise JsonRPCRequestException('No deferred requests to send.')
957938
def defer(callable):
    '''
    '''
    t = threading.Thread(target=callable)
    t.start()
    return t.join
171403
def ensure_async(function_original):
    

    def wrapper(*args, **kwargs):
        try:
            result = function_original(*args, **kwargs)
            if isinstance(result, Deferred):
                return result
            d = Deferred()
            d.callback(result)
            return d
        except:
            return fail()

    return wrapper
523141
function asynchChainDone(self, res) {
			if (typeof res !== 'undefined') {
				if (res instanceof Error) {
					self._state.success = null;
					self._state.error = res;
				} else {
					if (res && res._deep_undefined_)
						res = undefined;
					self._state.success = res;
					self._state.error = null;
				}
			}
			self._running = false; // asynch flag
			if (!self._executing) // real asynch event
				self._next();
		}
444869
private CompletableFuture<ExecutionResult> deferSupport(ExecutionContext executionContext, CompletableFuture<ExecutionResult> result) {
        return result.thenApply(er -> {
            DeferSupport deferSupport = executionContext.getDeferSupport();
            if (deferSupport.isDeferDetected()) {
                // we start the rest of the query now to maximize throughput.  We have the initial important results
                // and now we can start the rest of the calls as early as possible (even before some one subscribes)
                Publisher<ExecutionResult> publisher = deferSupport.startDeferredCalls();
                return ExecutionResultImpl.newExecutionResult().from(er)
                        .addExtension(GraphQL.DEFERRED_RESULTS, publisher)
                        .build();
            }
            return er;
        });

    }
118435
def track_deferrable(name, deferrable)
      attach_time = Time.now
      deferrable.callback do |*a|
        push_deferrable_values("#{name}_success", attach_time)
      end
      deferrable.errback do |*a|
        push_deferrable_values("#{name}_error", attach_time)
      end
    end
711417
def await_message(self, *args, **kwargs) -> 'asyncio.Future[Message]':
        
        fut = asyncio.Future()
        @self.on_message(*args, **kwargs)
        async def handler(message):
            fut.set_result(message)
        # remove handler when done or cancelled
        fut.add_done_callback(lambda _: self.remove_message_handler(handler))
        return fut
173727
def +@
      response = Fiber.yield(Delayer::Deferred::Request::Await.new(self))
      if response.ok?
        response.value
      else
        Delayer::Deferred.fail(response.value)
      end
    end
1339365
async def _deferred_init(self):
        

        await self._check_subscriptions()
        await self._set_whitelist()
        await self._set_get_started()
        await self._set_greeting_text()
        await self._set_persistent_menu()
1025254
def until_protocol(self, timeout=None):
        
        t0 = self.ioloop.time()
        yield self.until_running(timeout=timeout)
        t1 = self.ioloop.time()
        if timeout:
            timedelta = timeout - (t1 - t0)
        else:
            timedelta = None
        assert get_thread_ident() == self.ioloop_thread_id
        yield self._received_protocol_info.until_set(timeout=timedelta)