XXX revert to async version
975726
function editDeleted(objId, req, res, next) {
  models.Deleted.findById(objId).then(function(obj) {
    if (!obj) {
      return next(); // not found
    }
    obj.setPrinciple(req.user);
    obj.ensure('view');
    var deletedModel = getModelFromId(obj.deletedId);
    var refs = [];
    var foreignKeys = {};
    addRefs(deletedModel.schema, refs, foreignKeys);
    // fetch it again with refs populated
    return runQuery(models.Deleted, refs, {_id: objId}, null, 'object.').then(function(docs) {
      obj = docs && docs[0];
      var restored = new deletedModel();
      restored.set(obj.object);
      restored.setPrinciple(req.user);
      restored.ensure('view');
      utils.resolvePromises(foreignKeys).then(function(foreignKeys) {
        render({deleteId: objId, creating: true, foreignKeys:foreignKeys},
                deletedModel, restored, req, res, next);
      }, next);
    });
  }, next);
}
972205
def resync_package(ctx, opts, owner, repo, slug, skip_errors):
    """"""
    click.echo(
        "Resynchonising the %(slug)s package ... "
        % {"slug": click.style(slug, bold=True)},
        nl=False,
    )

    context_msg = "Failed to resynchronise package!"
    with handle_api_exceptions(
        ctx, opts=opts, context_msg=context_msg, reraise_on_error=skip_errors
    ):
        with maybe_spinner(opts):
            api_resync_package(owner=owner, repo=repo, identifier=slug)

    click.secho("OK", fg="green")
1182527
function unqueue(done) {
    var storage = this;

    this.redis().lpop(this.queueKey(), function(err, key) {
        if (err) return done(err);

        storage.redis().get(key, function(err, task) {
            if (err) return done(err);
            if (!task) return done();

            storage.redis().del(key);
            done(null, JSON.parse(task), key);
        });
    });
}
675594
@Override
    public CompletableFuture<Void> refreshAsync(String key, int expireSeconds) {
        return setExpireSecondsAsync(key, expireSeconds);
    }
376322
function saveSync(taskName) {
  if(!this.config.savefile) return null;
  var json = loadSync.call(this) || {};
  json[taskName] = new Date().getTime();
  fs.writeFile(this.config.savefile, JSON.stringify(json), { encoding: 'utf8' }, function(err) {
    if(err) {
      log.warn('Crux.tasks: failed to save dumpfile.');
    }
  });
}
207320
async function (events) {
    const oThis = this
      , promiseArray = []
    ;

    // nothing to do
    if (!events || events.length === 0) {
      oThis.updateIntercomDataFile();
      return Promise.resolve();
    }

    //TODO: last processed transaction index.
    for (var i = 0; i < events.length; i++) {
      const eventObj = events[i]
        , j = i
      ;

      // await oThis.processEventObj(eventObj);

      if (oThis.parallelProcessingAllowed()) {
        promiseArray.push(new Promise(function (onResolve, onReject) {
          setTimeout(function () {
            oThis.processEventObj(eventObj)
              .then(onResolve)
              .catch(function (error) {
                logger.error('##### inside catch block #####: ', error);
                return onResolve();
              });
          }, (j * 1000 + 100));
        }));
      } else {
        await oThis.processEventObj(eventObj)
          .catch(function (error) {
            logger.error('inside catch block: ', error);
            return Promise.resolve();
          });
      }
    }

    if (oThis.parallelProcessingAllowed()) {
      await Promise.all(promiseArray);
    }

    oThis.updateIntercomDataFile();
    return Promise.resolve();
  }
494913
public Task revertToCurrentSnapshot_Task(HostSystem host, Boolean suppressPowerOn) throws VmConfigFault, SnapshotFault, TaskInProgress, InvalidState, InsufficientResourcesFault, NotFound, RuntimeFault, RemoteException {
        ManagedObjectReference mor = getVimService().revertToCurrentSnapshot_Task(getMOR(), host == null ? null : host.getMOR(), suppressPowerOn);
        return new Task(getServerConnection(), mor);
    }
903143
function(callback) {
    var packageToVersions = this.packageToVersions;
    var count = Package.versionCount(packageToVersions);
    if (count === 0) {
      return callback && callback();
    }

    // For each package version, check shasum and copy to server root.
    var packages = Object.keys(packageToVersions);
    async.parallel(
      packages
        .map(function(package) {
          var versions = Object.keys(packageToVersions[package]);
          return versions.map(function(version) {
            return this.verifyPackageVersion.bind(this, package, version);
          }.bind(this));
        }.bind(this))
        .reduce(function(prev, curr) {
          return prev.concat(curr);
        }),
      function(err) {
        if (err) {
          return callback && callback(err);
        }

        ncp(this.tempdir, this.root, callback);
      }.bind(this)
    );
  }
1314334
async function updateVersion (version) {
  const versionPath = path.resolve(__dirname, '..', 'ELECTRON_VERSION')
  await writeFile(versionPath, version, 'utf8')
}
1309259
def drop(self, async_=False, if_exists=False, **kw):
        
        async_ = kw.get('async', async_)
        return self.parent.delete(self, async_=async_, if_exists=if_exists)
441813
async function () {
        let redirectURL = ctx.url;
        try {
          redirectURL = encodeURIComponent(redirectURL);
        } catch (e) {
          // URIError: URI malformed
          // use source url
        }
        const loginURL = options.loginPath + '?redirect=' + redirectURL;
        debug('redirect to %s', loginURL);
        redirect(ctx, loginURL);
      }
558159
function done(err, content) {
            if (err) return cb(err);

            var code = JSON.parse(self.square.package.source)
              , current = bundle.version || self.version(bundle.meta.content)
              , source;

            code.bundle[key].version = version;
            bundle.version = version;
            bundle.content = content;

            // now that we have updated the shizzle, we can write a new file
            // also update the old source with the new version
            source = JSON.stringify(code, null, 2);
            self.square.package.source = source;

            try {
              async.parallel([
                  async.apply(fs.writeFile, self.square.package.location, source)
                , async.apply(fs.writeFile, bundle.meta.location, content)
              ], function (err, results) {
                self.square.logger.notice(
                    'sucessfully updated %s from version %s to %s'
                  , key
                  , current.grey
                  , version.green
                );

                cb(err);
              });
            } catch (e) { err = e; }
          }
1202873
async function (rid, varName, query, val) {
      const ops = await putPVar(ldb, ['appvars', rid, varName], query, val)
      await ldb.batch(ops)
    }
1370448
function handleSuccess() {
  clearOutdatedErrors();

  var isHotUpdate = !isFirstCompilation;
  isFirstCompilation = false;
  hasCompileErrors = false;

  // Attempt to apply hot updates or reload.
  if (isHotUpdate) {
    tryApplyUpdates(function onHotUpdateSuccess() {
      // Only dismiss it when we're sure it's a hot update.
      // Otherwise it would flicker right before the reload.
      tryDismissErrorOverlay();
    });
  }
}
463208
function(callback) {
    async.waterfall([
      // Make root directory.
      maybeMkdir.bind(null, this.root),

      // Make tmp directory.
      function(done) {
        this.tempdir = path.join(this.root, '.tmp');
        maybeMkdir(this.tempdir, { purge: true }, done);
      }.bind(this),

      // Make directories for each package, package version.
      function(done) {
        var dirs = [];
        for (var package in this.packageToVersions) {
          dirs.push(path.resolve(this.tempdir, package));
          var versions = this.packageToVersions[package];
          for (var version in versions) {
            dirs.push(path.resolve(this.tempdir, package, version));
          }
        }

        async.parallel(dirs.map(function(dir) {
          return maybeMkdir.bind(null, dir);
        }), function(err) {
          return done && done(err);
        });
      }.bind(this)
    ], callback);
  }
1305564
function onupgrade(to){
    if (transport && to.name != transport.name) {
      debug('"%s" works - aborting "%s"', to.name, transport.name);
      freezeTransport();
    }
  }
1224660
async function deferSession(ctx, next) {
    ctx.sessionStore = store

    // TODO:
    // Accessing ctx.session when it's defined is causing problems
    // because it has side effect. So, here we use a flag to determine
    // that session property is already defined.
    if (ctx.__isSessionDefined) {
      return next()
    }
    let isNew = false
    let originalHash = null
    let touchSession = false
    let getter = false

    // if path not match
    if (!matchPath(ctx)) {
      return next()
    }

    addCommonAPI(ctx)

    Object.defineProperty(ctx, 'session', {
      async get() {
        if (touchSession) {
          return this._session
        }
        touchSession = true
        getter = true

        const result = await getSession(this)
        // if cookie path not match
        // this route's controller should never use session
        if (!result) return

        originalHash = result.originalHash
        isNew = result.isNew
        this._session = result.session
        return this._session
      },
      set(value) {
        touchSession = true
        this._session = value
      }
    })

    // internal flag to determine that session is already defined
    ctx.__isSessionDefined = true

    ctx.regenerateSession = async function regenerateSession() {
      debug('regenerating session')
      // make sure that the session has been loaded
      await ctx.session

      if (!isNew) {
        // destroy the old session
        debug('destroying previous session')
        await store.destroy(ctx.sessionId)
      }

      ctx._session = generateSession()
      ctx.sessionId = genSid.call(ctx, 24)
      sessionIdStore.reset.call(ctx)
      debug('created new session: %s', ctx.sessionId)
      isNew = true
      return ctx._session
    }

    await next()

    if (touchSession) {
      // if only this.session=, need try to decode and get the sessionID
      if (!getter) {
        ctx.sessionId = sessionIdStore.get.call(ctx)
      }

      await refreshSession(ctx, ctx._session, originalHash, isNew)
    }
  }