Initialise a Tornado AsyncClient and send the request to the sentry
        server. If the callback is a callable, it will be called with the
        response.
776036
def _send_remote(self, url, data, headers=None, callback=None):
        
        if headers is None:
            headers = {}

        return AsyncHTTPClient().fetch(
            url, callback, method="POST", body=data, headers=headers,
            validate_cert=self.validate_cert
        )
141973
def _handle_request(self, request):
        """"""
        if 'types' in self.method_data[request['method']]:
            self._validate_params_types(request['method'], request['params'])

        if self.serve_exception:
            raise self.serve_exception()
        d = self._call_method(request)
        self.pending.add(d)
        if self.timeout:
            timeout_deferred = self.reactor.callLater(self.timeout, d.cancel)

            def completed(result):
                if timeout_deferred.active():
                    # cancel the timeout_deferred if it has not been fired yet
                    # this is to prevent d's deferred chain from firing twice
                    # (and raising an exception).
                    timeout_deferred.cancel()
                return result
            d.addBoth(completed)
        try:
            result = yield d
        except defer.CancelledError:
            # The request was cancelled due to a timeout or by cancelPending
            # having been called. We return a TimeoutError to the client.
            self._remove_pending(d)
            raise TimeoutError()
        except Exception as e:
            self._remove_pending(d)
            raise e
        self._remove_pending(d)
        # Do not respond to notifications.
        if request['id'] is None:
            defer.returnValue(None)

        respond = {}
        self._fill_ver(request['jsonrpc'], respond)
        respond['result'] = result
        respond['id'] = request['id']

        defer.returnValue(respond)
1046450
public void sendAsync(final MailRequestCallback callback) {
        if (!configuration.mailSendFilter().filter(this)) return;
        prepareSend();
        request()
                .async()
                .post(entity(),
                      new InvocationCallback<javax.ws.rs.core.Response>() {
                          @Override
                          public void completed(javax.ws.rs.core.Response o) {
                              callback.completed(new Response(o));
                          }

                          @Override
                          public void failed(Throwable throwable) {
                              callback.failed(throwable);
                          }
                      });
    }
1243313
private void initialize(Handler callbackHandler, int threadPoolSize) {
		mDownloadDispatchers = new DownloadDispatcher[threadPoolSize];
		mDelivery = new CallBackDelivery(callbackHandler);
	}
78015
def get_event(self,
                  request,
                  tag='',
                  matcher=prefix_matcher.__func__,
                  callback=None,
                  timeout=None
                  ):
        '''
        
        '''
        # if the request finished, no reason to allow event fetching, since we
        # can't send back to the client
        if request._finished:
            future = Future()
            future.set_exception(TimeoutException())
            return future

        future = Future()
        if callback is not None:
            def handle_future(future):
                tornado.ioloop.IOLoop.current().add_callback(callback, future)
            future.add_done_callback(handle_future)
        # add this tag and future to the callbacks
        self.tag_map[(tag, matcher)].append(future)
        self.request_map[request].append((tag, matcher, future))

        if timeout:
            timeout_future = tornado.ioloop.IOLoop.current().call_later(timeout, self._timeout_future, tag, matcher, future)
            self.timeout_map[future] = timeout_future

        return future
285830
async def send(self, *args, **kwargs):
        """"""
        for callback in self:
            res = callback(*args, **kwargs)
            if asyncio.iscoroutine(res) or isinstance(res, asyncio.Future):
                await res
719011
def _execute_callback(async, callback):
    
    from furious.async import Async

    if not callback:
        return async.result.payload

    if isinstance(callback, Async):
        return callback.start()

    return callback()
882332
def on(f):
    
    action = f.__name__
    f.action = action

    @wrapt.decorator
    @tornado.gen.coroutine
    def _execute(wrapped, instance, args, kwargs):
        return wrapped(*args, **kwargs)

    return _execute(f)
1102649
def run(self, port): # pragma: no coverage
        
        tornado.options.parse_command_line()
        http_server = tornado.httpserver.HTTPServer(self)
        http_server.listen(port)
        tornado.ioloop.IOLoop.instance().start()
390817
function init (prefs, callback) {
	options = _.extend(defaults, prefs);
	app = options.app || express();
	app.use(cors());

	ramlMocker.generate(options, process(function(requestsToMock){
		requestsToMock.forEach(function(reqToMock){
			addRoute(reqToMock);
		});
		log(new Array(30).join('='));
		log('%s[%s]%s API routes generated', colors.qyan, requestsToMock.length, colors.default);

		if(typeof callback === 'function'){
			callback(app);
		}
	}));

	var watcher = watch();
	var server = launchServer(app);

	function close () {
		if (watcher) { watcher.close(); }
		if (server) { server.close(); }
	}

	return {
		close: close,
		server: server,
		watcher: watcher
	};
}
732494
def callback(self, request, **kwargs):
        
        return super(ServiceTwitter, self).callback(request, **kwargs)
1305906
async def send(self, request: Request, **config: Any) -> Response:
        
        return Response(
            request,
            await self.driver.send(request.http_request)
        )
534831
protected void deliveryAsyncResult(Request request, HttpCallback<?> callback) {
        Util.log("onDelivery:" + request.url().toString());
        final HttpCallback<?> resCallBack = callback == null ? new DefaultCallback() : callback;

        //Call start
        callStart(resCallBack, request);

        mOkHttpClient.newCall(request).enqueue(new Callback() {
            public void onFailure(Call call, IOException e) {
                Util.log("onFailure:" + call.request().toString());
                callFailure(resCallBack, call.request(), null, e);
                callFinish(resCallBack);
            }

            public void onResponse(Call call, Response response) {
                try {
                    Object ret = null;
                    final String string = response.body().string();
                    final boolean haveValue = !TextUtils.isEmpty(string);

                    Util.log("onResponse:Code:%d Body:%s.", response.code(), (haveValue ? string : "null"));

                    if (haveValue) {
                        ret = mResolver.analysis(string, resCallBack.getClass());
                    }

                    callSuccess(resCallBack, ret, response.code());
                } catch (Exception e) {
                    Util.log("onResponse Failure:" + response.request().toString());
                    callFailure(resCallBack, response.request(), response, e);
                }
                callFinish(resCallBack);
            }
        });
    }
947634
def call(
        self,
        scheme,
        service,
        arg1,
        arg2=None,
        arg3=None,
        timeout=None,
        retry_on=None,
        retry_limit=None,
        routing_delegate=None,
        hostport=None,
        shard_key=None,
        tracing_span=None,
        trace=None,  # to trace or not, defaults to self._dep_tchannel.trace
        caller_name=None,
    ):
        

        # TODO - don't use asserts for public API
        assert format, "format is required"
        assert service, "service is required"
        assert arg1, "arg1 is required"

        # default args
        if arg2 is None:
            arg2 = ""
        if arg3 is None:
            arg3 = ""
        if timeout is None:
            timeout = DEFAULT_TIMEOUT
        if retry_on is None:
            retry_on = retry.DEFAULT
        if retry_limit is None:
            retry_limit = retry.DEFAULT_RETRY_LIMIT

        # TODO - allow filters/steps for serialization, tracing, etc...

        tracing.apply_trace_flag(tracing_span, trace, self._dep_tchannel.trace)

        # calls tchannel.tornado.peer.PeerClientOperation.__init__
        operation = self._dep_tchannel.request(
            service=service,
            hostport=hostport,
            arg_scheme=scheme,
            retry=retry_on,
            tracing_span=tracing_span
        )

        # fire operation
        transport_headers = {
            transport.SCHEME: scheme,
            transport.CALLER_NAME: caller_name or self.name,
        }
        if shard_key:
            transport_headers[transport.SHARD_KEY] = shard_key
        if routing_delegate:
            transport_headers[transport.ROUTING_DELEGATE] = routing_delegate

        response = yield operation.send(
            arg1=arg1,
            arg2=arg2,
            arg3=arg3,
            headers=transport_headers,
            retry_limit=retry_limit,
            ttl=timeout,
        )

        # unwrap response
        body = yield response.get_body()
        headers = yield response.get_header()
        t = TransportHeaders.from_dict(response.headers)
        result = Response(
            body=body,
            headers=headers,
            transport=t,
            status=response.code,
        )

        raise gen.Return(result)
449406
def _init_stream(self):
        '''
        '''
        assert not self._control_connection
        self._control_connection = yield from self._acquire_request_connection(self._request)
        self._control_stream = ControlStream(self._control_connection)
        self._commander = Commander(self._control_stream)

        read_callback = functools.partial(self.event_dispatcher.notify, self.Event.control_receive_data)
        self._control_stream.data_event_dispatcher.add_read_listener(read_callback)

        write_callback = functools.partial(self.event_dispatcher.notify, self.Event.control_send_data)
        self._control_stream.data_event_dispatcher.add_write_listener(write_callback)
99431
def init_sentry(self,):
        
        if not self.use_sentry:
            return

        sentry_config = self.keychain.get_service("sentry")

        tags = {
            "repo": self.repo_name,
            "branch": self.repo_branch,
            "commit": self.repo_commit,
            "cci version": cumulusci.__version__,
        }
        tags.update(self.config.get("sentry_tags", {}))

        env = self.config.get("sentry_environment", "CumulusCI CLI")

        self.sentry = raven.Client(
            dsn=sentry_config.dsn,
            environment=env,
            tags=tags,
            processors=("raven.processors.SanitizePasswordsProcessor",),
        )
1052637
def connect(self, callback=None, timeout=None):
        '''
        
        '''
        if hasattr(self, '_connecting_future') and not self._connecting_future.done():  # pylint: disable=E0203
            future = self._connecting_future  # pylint: disable=E0203
        else:
            if hasattr(self, '_connecting_future'):
                # read previous future result to prevent the "unhandled future exception" error
                self._connecting_future.exception()  # pylint: disable=E0203
            future = tornado.concurrent.Future()
            self._connecting_future = future
            self._connect(timeout=timeout)

        if callback is not None:
            def handle_future(future):
                response = future.result()
                self.io_loop.add_callback(callback, response)
            future.add_done_callback(handle_future)

        return future