Returns a macaroon from a legacy wait endpoint.
195404
def _wait_for_macaroon(wait_url):
    ''' 
    '''
    headers = {
        BAKERY_PROTOCOL_HEADER: str(bakery.LATEST_VERSION)
    }
    resp = requests.get(url=wait_url, headers=headers)
    if resp.status_code != 200:
        raise InteractionError('cannot get {}'.format(wait_url))

    return bakery.Macaroon.from_dict(resp.json().get('Macaroon'))
63849
public static Object waitForServiceStartup(BundleContext context, String interfaceClassName, String serviceClassName, String versionRange, Dictionary<String, String> filter, int secsToWait)
    {
        if (interfaceClassName == null)
            interfaceClassName = serviceClassName;
        ServiceReference ref = BaseClassFinderService.getClassServiceReference(context, interfaceClassName, versionRange, filter);
        if (ref != null)
        {   // Good, it's registered - make sure it's started, or just start it!
            if (ClassFinderActivator.waitForBundleStartup(context, ref.getBundle(), secsToWait))
                return ref.getBundle().getBundleContext().getService(ref);
            else
                return null;    // Never
        }
        
        Bundle bundle = BaseClassFinderService.findBundle(context, ClassFinderActivator.getPackageName(serviceClassName, false), versionRange);
        if (bundle == null)
            if (serviceClassName != null)
                if (!serviceClassName.equals(ClassFinder.class.getName())) // Never. This code is in this bundle.
        {
            ClassFinder classFinder = getClassFinder(context, secsToWait);        
            String packageName = ClassFinderActivator.getPackageName(serviceClassName, false);
            Object resource = classFinder.deployThisResource(packageName, versionRange, true);  // Get the bundle info from the repos
            bundle = (Bundle)classFinder.findBundle(resource, context, packageName, versionRange);
        }
        if (bundle == null)
            return null;    // Error, can't find bundle
        
        Thread thread = Thread.currentThread();
        ServiceRegisteredListener classFinderListener = null;
        try {
            context.addServiceListener(classFinderListener = new ServiceRegisteredListener(thread, bundleContext), "(" + Constants.OBJECTCLASS + "=" + interfaceClassName + ")");
        } catch (InvalidSyntaxException e) {
            e.printStackTrace();
        }
        if (!ClassFinderActivator.waitForBundleStartup(context, bundle, secsToWait))
            return null;
        // Double-check to make sure it didn't startup while I was doing all this.
        Object bundleService = getClassFinder(context, secsToWait).getClassBundleService(interfaceClassName, serviceClassName, versionRange, filter, 0);
        if (bundleService == null)
        { // Wait 15 seconds for the ClassService to come up while the activator starts this service
            synchronized (thread) {
                try {
                    thread.wait((secsToWait == -1) ? DEFAULT_SERVICE_WAIT_SECS * 1000 : secsToWait * 1000);    // Will notify me when it is up
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        context.removeServiceListener(classFinderListener);
        
        ref = BaseClassFinderService.getClassServiceReference(context, interfaceClassName, versionRange, filter);
        if (ref == null)
        {
            ClassServiceUtility.log(context, LogService.LOG_WARNING, "The " + interfaceClassName + " service was never registered - make sure you start it!");
            return null;
        }
        return ref.getBundle().getBundleContext().getService(ref);
    }
963177
@Deprecated
    public static RequestQueue getRequestQueue(Context context) {
        if (InstanceRequestQueue == null) {
            InstanceRequestQueue = newRequestQueue(context);
        }
        return InstanceRequestQueue;
    }
869997
def request_pick_fruit(self, req):
        """"""
        r = random.choice(self.FRUIT + [None])
        if r is None:
            return ("fail", "No fruit.")
        delay = random.randrange(1,5)
        req.inform("Picking will take %d seconds" % delay)

        def pick_handler():
            self._fruit_result.set_value(r)
            req.reply("ok", r)

        self.ioloop.add_callback(
            self.ioloop.call_later, delay, pick_handler)

        raise AsyncReply
374405
function getAsyncContent(url, options) {
            var requestCfg;
            // Initial options to be merged with the user's options
            options = tiny.extend({
                'method': 'GET',
                'params': '',
                'waiting': '<div class="ch-loading-large"></div>'
            }, defaults, options);

            // Set loading
            setAsyncContent({
                'status': 'waiting',
                'response': options.waiting
            });

            requestCfg = {
                method: options.method,
                success: function(resp) {
                    setAsyncContent({
                        'status': 'done',
                        'response': resp
                    });
                },
                error: function(err) {
                    setAsyncContent({
                        'status': 'error',
                        'response': '<p>Error on ajax call.</p>',
                        'data': err.message || JSON.stringify(err)
                    });
                }
            };

            if (options.cache !== undefined) {
                that._options.cache = options.cache;
            }

            if (options.cache === false && ['GET', 'HEAD'].indexOf(options.method.toUpperCase()) !== -1) {
                requestCfg.cache = false;
            }

            if (options.params) {
                if (['GET', 'HEAD'].indexOf(options.method.toUpperCase()) !== -1) {
                    url += (url.indexOf('?') !== -1 || options.params[0] === '?' ? '' : '?') + options.params;
                } else {
                    requestCfg.data = options.params;
                }
            }

            // Make a request
            tiny.ajax(url, requestCfg);
        }
1009985
@Override
    public Object get() throws InterruptedException, ExecutionException {
        ScheduledFuture<?> curr;
        synchronized (this.triggerContextMonitor) {
            curr = this.currentFuture;
        }
        return curr.get();
    }
1319807
def get_async(cls, blob_key, **ctx_options):
    """"""
    if not isinstance(blob_key, (BlobKey, basestring)):
      raise TypeError('Expected blob key, got %r' % (blob_key,))
    if 'parent' in ctx_options:
      raise TypeError('Parent is not supported')
    return cls.get_by_id_async(str(blob_key), **ctx_options)
708621
def _wait_until(obj, att, desired, callback, interval, attempts, verbose,
        verbose_atts):
    
    if not isinstance(desired, (list, tuple)):
        desired = [desired]
    if verbose_atts is None:
        verbose_atts = []
    if not isinstance(verbose_atts, (list, tuple)):
        verbose_atts = [verbose_atts]
    infinite = (attempts == 0)
    attempt = 0
    start = time.time()
    while infinite or (attempt < attempts):
        try:
            # For servers:
            obj.get()
        except AttributeError:
            try:
                # For other objects that don't support .get()
                obj = obj.manager.get(obj.id)
            except AttributeError:
                # punt
                raise exc.NoReloadError("The 'wait_until' method is not "
                        "supported for '%s' objects." % obj.__class__)
        attval = getattr(obj, att)
        if verbose:
            elapsed = time.time() - start
            msgs = ["Current value of %s: %s (elapsed: %4.1f seconds)" % (
                    att, attval, elapsed)]
            for vatt in verbose_atts:
                vattval = getattr(obj, vatt, None)
                msgs.append("%s=%s" % (vatt, vattval))
            print(" ".join(msgs))
        if attval in desired:
            return obj
        time.sleep(interval)
        attempt += 1
    return obj
1214018
def get(self, endpoint, params=None, version='1.1'):
        """"""
        return self.request(endpoint, params=params, version=version)
1141676
def wait(self, timeout: Union[float, datetime.timedelta] = None) -> Awaitable[None]:
        
        fut = Future()  # type: Future[None]
        if self._value:
            fut.set_result(None)
            return fut
        self._waiters.add(fut)
        fut.add_done_callback(lambda fut: self._waiters.remove(fut))
        if timeout is None:
            return fut
        else:
            timeout_fut = gen.with_timeout(
                timeout, fut, quiet_exceptions=(CancelledError,)
            )
            # This is a slightly clumsy workaround for the fact that
            # gen.with_timeout doesn't cancel its futures. Cancelling
            # fut will remove it from the waiters list.
            timeout_fut.add_done_callback(
                lambda tf: fut.cancel() if not fut.done() else None
            )
            return timeout_fut
527993
def get(self, lazy=False, **kwargs):
        
        result = self._get(limit=2, lazy=lazy, **kwargs)
        if len(result) > 1:
            raise MultipleNodesReturned(repr(kwargs))
        elif not result:
            raise self.source_class.DoesNotExist(repr(kwargs))
        else:
            return result[0]
248330
def _get(app, endpoint, id=None, auth_required=False, **kwargs):
    '''
    
    '''
    nb = _nb_obj(auth_required=auth_required)
    if id:
        item = getattr(getattr(nb, app), endpoint).get(id)
    else:
        kwargs = __utils__['args.clean_kwargs'](**kwargs)
        item = getattr(getattr(nb, app), endpoint).get(**kwargs)
    return item
77262
def api(func=None, timeout=API_TIMEOUT):  # incoming
    
    if func is None:
        return partial(api, timeout=timeout)
    else:
        wrapper = _get_api_decorator(func=func, timeout=timeout)
        return wrapper
1221669
def get_or_create_from_legacy_response(self, response, **kwargs):
        '''
        
        '''
        response_cls = self.response_class(**kwargs).get_or_create(**kwargs)
        if not getattr(response_cls, self.column):
            setattr(response_cls, self.column, self.accessor(response))
            _action_and_commit(response_cls, session.add)
        if not getattr(response_cls, self.venue_column):
            setattr(
                response_cls, self.venue_column, self.venue_accessor(response))
            _action_and_commit(response_cls, session.add)
1020695
function fetchWithRetry(url, options) {
    async function fetchWrapper() {
        const response = await fetch(url, options);
        // don't retry if status is 4xx
        if (response.status >= 400 && response.status < 500) {
            const contentType = response.headers.get('content-type');
            if (contentType && contentType.includes('application/json')) {
                const body = await response.json();
                throw new p_retry_1.default.AbortError(body.message);
            }
            else {
                throw new p_retry_1.default.AbortError(response.statusText);
            }
        }
        return response;
    }
    return p_retry_1.default(fetchWrapper, { retries: RETRY_COUNT });
}
1372835
def get(self, name=None):
        
        return self.__app.recipes.get(name, self._plugin)
568657
def _serialize_v2(self, macaroon):
        '''
        '''
        serialized = {}
        _add_json_binary_field(macaroon.identifier_bytes, serialized, 'i')
        _add_json_binary_field(binascii.unhexlify(macaroon.signature_bytes),
                               serialized, 's')

        if macaroon.location:
            serialized['l'] = macaroon.location
        if macaroon.caveats:
            serialized['c'] = [
                _caveat_v2_to_dict(caveat) for caveat in macaroon.caveats
            ]
        return json.dumps(serialized)