After receiving the data, generate the deferreds and add myself to it.
16586
def dataReceived(self, data):
        
        def write(result):
            print "Writing %r" % result
            self.transport.write(result)
        d = self.d()
        d.addCallback(write)  # errors are silently ignored!
        d.callback(data)
1199548
function startClient(httpBackend, client) {
    httpBackend.when("GET", "/pushrules").respond(200, {});
    httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
    httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA);

    client.startClient();

    // set up a promise which will resolve once the client is initialised
    const deferred = Promise.defer();
    client.on("sync", function(state) {
        console.log("sync", state);
        if (state != "SYNCING") {
            return;
        }
        deferred.resolve();
    });

    return Promise.all([
        httpBackend.flushAllExpected(),
        deferred.promise,
    ]);
}
1183700
def submit(self, call, *args, **kwargs):
        
        future = StoredFuture(call, *args, **kwargs)
        self._queue.put(future)
        self._ensure_worker()
        return future
601516
def add_future(self, future, callback):
        
        assert is_future(future)
        callback = stack_context.wrap(callback)
        future.add_done_callback(
            lambda future: self.add_callback(callback, future))
874563
def add_callbacks(self, future, callback, errback):
        
        def done(f):
            try:
                res = f.result()
                if callback:
                    callback(res)
            except Exception:
                if errback:
                    errback(create_failure())
        return future.add_done_callback(done)
197718
function() {
        return Promise.all([
            this._loadAccountData(),
            this._loadSyncData(),
        ]).then(([accountData, syncData]) => {
            console.log(
                `LocalIndexedDBStoreBackend: loaded initial data`,
            );
            this._syncAccumulator.accumulate({
                next_batch: syncData.nextBatch,
                rooms: syncData.roomsData,
                groups: syncData.groupsData,
                account_data: {
                    events: accountData,
                },
            });
        });
    }
574347
def _populate(self):
        """"""
        self.add(self._core_data)
        if self.initial_data:
            self.add(self.initial_data)
694299
function () {
    var self = this;
    var future = new Future;
    self.onAllCommitted(function () {
      future['return']();
    });
    self.arm();
    future.wait();
  }
455108
function generate(target, data, done) {
        var files = this.files,
            dest = null,
            paths = [],
            promises = [],
            folders = [];

        //by default, we generate a table of contents called readme.md
        var options = this.options({
            contentsEnabled: true,
            contentsFile: 'readme.md',
            contentsTitle: 'Documentation',
            templateDir: null
        });

        //map the list of files we'll be generating documentation for
        files.forEach(function(group) {
            dest = group.dest;
            group.src.filter(function(file) {
                var obj = {
                    filename: path.basename(file),
                    folder: path.dirname(file),
                    path: file
                };

                if(options.pathFilter)
                    obj.folder = obj.folder.replace(options.pathFilter, '');

                folders.push(obj);
            });
        });

        //map the set of folders, sort, and generate documentation
        folders = _(folders)
            .groupBy(function(p) { return p.folder; })
            .sortBy(function(p) { return p.length && p[0].folder; })
            .map(function(group) {
                var file = group.length && group[0] || {};
                return {
                    name: file.folder,
                    path: file.path.replace(file.filename, ''),
                    files: group,
                    fileData: {}
                };
            })
            .each(function(folder) {
                var def = Q.defer();

                //queue the promise for the docs, and ensure the target exists (can safely run on an existing folder)
                promises.push(def.promise);
                grunt.file.mkdir(dest +'/'+ folder.name);

                //generate the docs for the folder, resolving the promise when complete
                jsdox.generateForDir(folder.path, dest +'/'+ folder.name, options.templateDir, def.resolve, function(file, fileData) {
                    folder.fileData[file] = fileData;
                });
            });

        //when all docs have been generated, build the table of contents, if needed (this stuff should be moved into a template)
        Q.all(promises).then(function() {
            if(!options.contentsEnabled) return done();

            var buf = [],
                w = function() { buf.push.apply(buf, arguments); };

            w(options.contentsTitle || 'Documentation', '===');

            folders.forEach(function(folder) {
                var docs = [];

                //derive the set of documents we *actually* generated docs for; that way we only add documented
                //code to the table of contents
                folder.files.forEach(function(file) {
                    //reset the path, pointing to the markdown file, and set the file data parsed by jsdox
                    file.path = path.join(file.folder, file.filename.replace('.js', '')).replace(/^\//, '');
                    file.data = folder.fileData[file.filename]||{};
                    if(grunt.file.exists(dest, file.path + '.md')) docs.push(file);
                });

                if(docs.length > 0) {
                    w(folder.name || 'Root', '---');
                    w('name | overview', ':-- | :--');
                    docs.forEach(function(file) {
                        w('['+ file.path +'.js]('+ file.path + '.md' + ') | '+ (file.data.overview?'_'+ file.data.overview +'_':''));
                    });
                    w('- - -');
                }

                w('\n');
            });

            //write out the table of contents, and complete the async generate task
            fs.writeFileSync(path.join(dest, (options.contentsFile || 'readme.md')), buf.join('\n'));
            done();
        });
    }
387188
function (batch, response) {
                var data = response.data;
                for (var i = 0, requestId; i < batch.length; i++) {
                    requestId = this._getRequestId(batch[i].method, batch[i].params);
                    this._resolvePromise(this._deferreds[requestId], data[i]);
                    delete this._deferreds[requestId];
                }
            }
657798
protected void afterData() {
        final Set<StackState> state = scopeState.getFirst();
        state.add(StackState.WROTE_DATA);
    }
445797
function() {
    var pending = [],
        value, deferred;

    deferred = {

      resolve: function(val) {
        if (pending) {
          var callbacks = pending;
          pending = undefined;
          value = ref(val);

          if (callbacks.length) {
            nextTick(function() {
              var callback;
              for (var i = 0, ii = callbacks.length; i < ii; i++) {
                callback = callbacks[i];
                value.then(callback[0], callback[1]);
              }
            });
          }
        }
      },


      reject: function(reason) {
        deferred.resolve(reject(reason));
      },


      promise: {
        then: function(callback, errback) {
          var result = defer();

          var wrappedCallback = function(value) {
            try {
              result.resolve((callback || defaultCallback)(value));
            } catch(e) {
              exceptionHandler(e);
              result.reject(e);
            }
          };

          var wrappedErrback = function(reason) {
            try {
              result.resolve((errback || defaultErrback)(reason));
            } catch(e) {
              exceptionHandler(e);
              result.reject(e);
            }
          };

          if (pending) {
            pending.push([wrappedCallback, wrappedErrback]);
          } else {
            value.then(wrappedCallback, wrappedErrback);
          }

          return result.promise;
        }
      }
    };

    return deferred;
  }
724173
def defer_assignment(self, callable):
        """"""
        self._deferred_assignments.append((callable, self.scope_stack[:], self.offset))
931829
function() {
    var deferred = $q.defer();

    var current = $state.current();

    // Evaluate
    if(current) {
      var sources = (typeof current.load === 'string' ? [current.load] : current.load) || [];
      
      // Get promises
      $q.all(sources
        .map(function(src) {
          return _createLoadable(src);
        })
        .filter(function(loadable) {
          return !loadable.isComplete;
        })
        .map(function(loadable) {
          return loadable.promise;
        })
      )
          .then(function() {
            deferred.resolve();

          }, function(err) {
            $rootScope.$broadcast('$loadableError', err);
            deferred.reject(err);
          });

    // No state
    } else {
      deferred.resolve();
    }

    return deferred.promise;
  }
842940
function(){
      var data = {
        title: $('#new_item').val(),
        priority: todo.selected_priority,
        deadline: todo.create_deadline($('#due_in').val())
      }
      if (data.title == ''){
        return
      }
      $('#new_item').val('');
      todo.push_item(data); // Push data to CloudMine
    }
512291
function doSomethingUninteresting(data) {
  // simulate latency
  var wait = randomWait(1000);
  return Promise.delay(wait).then(
    () => `It took me ${wait} milliseconds to notice you gave me ${data}.`
  );
}
263045
function() {
                        var ca
                        _count--;
                        if (_count === 0) {
                            var args = Array.prototype.slice.call(arguments, 0);
                            deferredObject.resolve.apply(null,
                                ctxArgs.concat(args));
                        }
                    }