Defer target app retrieval until requested
776650
def target_app(self):
        """"""
        if self.__target_app is None:
            self.__target_app = self._swimlane.apps.get(id=self.__target_app_id)

        return self.__target_app
68261
def listen_until_return(self, *temporary_handlers, timeout=0):
        """"""
        start = time.time()
        while timeout == 0 or time.time() - start < timeout:
            res = self.listen(*temporary_handlers)
            if res is not None:
                return res
524177
def __get_or_create_app(self, url, cache_key):
        
        headers = {"Accept": "application/json"}
        app_url = '%s?datasource=%s' % (url, self.datasource)

        cached = self.cache.get(cache_key, (None, None, 0))
        if cached is None or len(cached) != 3:
            self.cache.invalidate(cache_key)
            cached_app, cached_headers, cached_expiry = (cached, None, 0)
        else:
            cached_app, cached_headers, cached_expiry = cached

        if cached_app is not None and cached_headers is not None:
            # we didn't set custom expire, use header expiry
            expires = cached_headers.get('expires', None)
            cache_timeout = -1
            if self.expire is None and expires is not None:
                cache_timeout = get_cache_time_left(
                    cached_headers['expires']
                )
                if cache_timeout >= 0:
                    return cached_app

            # we set custom expire, check this instead
            else:
                if self.expire == 0 or cached_expiry >= time.time():
                    return cached_app

            # if we have etags, add the header to use them
            etag = cached_headers.get('etag', None)
            if etag is not None:
                headers['If-None-Match'] = etag

            # if nothing makes us use the cache, invalidate it
            if ((expires is None or cache_timeout < 0 or
                 cached_expiry < time.time()) and etag is None):
                self.cache.invalidate(cache_key)

        # set timeout value in case we have to cache it later
        timeout = 0
        if self.expire is not None and self.expire > 0:
            timeout = time.time() + self.expire

        # we are here, we know we have to make a head call...
        res = requests.head(app_url, headers=headers)
        if res.status_code == 304 and cached_app is not None:
            self.cache.set(
                cache_key,
                (cached_app, res.headers, timeout)
            )
            return cached_app

        # ok, cache is not accurate, make the full stuff
        app = App.create(app_url)
        if self.caching:
            self.cache.set(cache_key, (app, res.headers, timeout))

        return app
769972
async def try_trigger_before_first_request_functions(self) -> None:
        """"""
        if self._got_first_request:
            return

        # Reverse the teardown functions, so as to match the expected usage
        self.teardown_appcontext_funcs = list(reversed(self.teardown_appcontext_funcs))
        for key, value in self.teardown_request_funcs.items():
            self.teardown_request_funcs[key] = list(reversed(value))
        for key, value in self.teardown_websocket_funcs.items():
            self.teardown_websocket_funcs[key] = list(reversed(value))

        async with self._first_request_lock:
            if self._got_first_request:
                return
            for function in self.before_first_request_funcs:
                await function()
            self._got_first_request = True
1217321
def fetch(self, wait=0):
        
        if self.started:
            return fetch(self.id, wait=wait, cached=self.cached)
430976
def get_current_app(self):
        """"""
        self.request(EP_GET_CURRENT_APP_INFO)
        return None if self.last_response is None else self.last_response.get('payload').get('appId')
224100
function defer(fn) { var args
        args = slice.call(arguments, 1)
        return delay.apply(this, [fn, 0].concat(args))
    }
355270
function reqToAppName(req) {
  var targetName = null;
  try {
    targetName = req.url.split('/').pop();
  } catch (e) {}
  return targetName || null;
}
239191
function waitForReady (method) {
  return function fetchSync_readyWrapper (...args) {
    if (hasStartedInit) return ready.promise.then(() => method(...args))
    throw new Error('initialise first with fetchSync.init()')
  }
}
1256100
def _prepare_fetch(self, request: Request, response: Response):
        '''
        '''
        self._request = request
        self._response = response

        yield from self._init_stream()

        connection_closed = self._control_connection.closed()

        if connection_closed:
            self._login_table.pop(self._control_connection, None)
            yield from self._control_stream.reconnect()

        request.address = self._control_connection.address

        connection_reused = not connection_closed
        self.event_dispatcher.notify(self.Event.begin_control, request, connection_reused=connection_reused)

        if connection_closed:
            yield from self._commander.read_welcome_message()

        yield from self._log_in()

        self._response.request = request
217721
def on_get(self, request, response, user_id=None):
        """"""
        response.body = "{}"
        if self.handler(user_id):
            response.status = falcon.HTTP_200
            self.api.register(utils.mxid2localpart(user_id))
        else:
            response.status = falcon.HTTP_404
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;
        });

    }
423715
def on_get(self, req, resp, **kwargs):
        """"""
        return super().on_get(
            req, resp, handler=self._retrieve, **kwargs
        )
563981
def waitStarted(self):
        """"""
        ns = None
        while not ns:
            try:
                time.sleep(3)
                ns = Pyro.naming.NameServerLocator(
                    identification=self.identification).getNS()
            except Pyro.errors.NamingError as er:
                pass
521269
def get_apps(self, offset=None, limit=None):
        
        params = {'project': self.id, 'offset': offset,
                  'limit': limit}
        return self._api.apps.query(api=self._api, **params)
296966
function () {
    var deferred = Q.defer();

    // store desired capabilities of this session
    this.desiredCapabilities = this.browserData.getDesiredCapabilities(this.browserName, this.config);
    this.browserDefaults = this.browserData.driverDefaults;
    this.browserDefaults.status = this.browserData.getStatusDefaults(this.desiredCapabilities);

    // start a browser session
    this._startBrowserSession(deferred, this.desiredCapabilities, this.browserDefaults);

    return deferred.promise;
  }
724173
def defer_assignment(self, callable):
        """"""
        self._deferred_assignments.append((callable, self.scope_stack[:], self.offset))