Invoke event in a background request.
184665
public void run()
    {
        try
        {
            // Open connection to URL calling this interceptor.
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            // Pass in the session id cookie to maintain the same session.
            log.trace("passing in cookies: ", cookies);
            connection.setRequestProperty("Cookie", cookies);
            // Invoke event in background.
            byte[] buff = new byte[1024 * 4];
            InputStream input = connection.getInputStream();
            try {
                while (input.read(buff) > -1);
            } finally {
                input.close();
            }
        }
        catch (Exception e)
        {
            // Log any exception that could have occurred.
            log.error(e);
        }
    }
1155363
def listen(cls, event, func):
        """"""
        signal(event).connect(func, sender=cls)
459176
def PopEvent(self):
    
    try:
      _, _, _, event = heapq.heappop(self._heap)
      return event

    except IndexError:
      return None
992555
async def _on_rpc_command(self, event):
        """"""

        payload = event['payload']
        rpc_id = payload['rpc_id']
        tag = payload['response_uuid']
        args = payload['payload']

        result = 'success'
        response = b''

        if self._rpc_dispatcher is None or not self._rpc_dispatcher.has_rpc(rpc_id):
            result = 'rpc_not_found'
        else:
            try:
                response = self._rpc_dispatcher.call_rpc(rpc_id, args)
                if inspect.iscoroutine(response):
                    response = await response
            except RPCInvalidArgumentsError:
                result = 'invalid_arguments'
            except RPCInvalidReturnValueError:
                result = 'invalid_response'
            except Exception: #pylint:disable=broad-except;We are being called in a background task
                self._logger.exception("Exception handling RPC 0x%04X", rpc_id)
                result = 'execution_exception'

        message = dict(response_uuid=tag, result=result, response=response)

        try:
            await self.send_command(OPERATIONS.CMD_RESPOND_RPC, message,
                                    MESSAGES.RespondRPCResponse)
        except:  #pylint:disable=bare-except;We are being called in a background worker
            self._logger.exception("Error sending response to RPC 0x%04X", rpc_id)
825156
def main(
    context: click.core.Context, method: str, request_type: str, id: Any, send: str
) -> None:
    
    exit_status = 0
    # Extract the jsonrpc arguments
    positional = [a for a in context.args if "=" not in a]
    named = {a.split("=")[0]: a.split("=")[1] for a in context.args if "=" in a}
    # Create the request
    if request_type == "notify":
        req = Notification(method, *positional, **named)
    else:
        req = Request(method, *positional, request_id=id, **named)  # type: ignore
    # Sending?
    if send:
        client = HTTPClient(send)
        try:
            response = client.send(req)
        except JsonRpcClientError as e:
            click.echo(str(e), err=True)
            exit_status = 1
        else:
            click.echo(response.text)
    # Otherwise, simply output the JSON-RPC request.
    else:
        click.echo(str(req))
    sys.exit(exit_status)
94196
function (done) {
      if (called) return;

      called = true;

      // wait for req events to fire
      process.nextTick(function() {
        if (waitend && req.readable) {
          // dump rest of request
          req.resume();
          req.once('end', done);
          return;
        }

        done();
      });
    }
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
725516
def getEvent(self, dev_id, starttime, endtime):
        """"""
        path = 'device/%s/event?startTime=%s&endTime=%s' % \
            (dev_id, starttime, endtime)
        return self.rachio.get(path)
535081
def emit_event(self, event):
        """"""
        with self._lock:
            listeners = list(self._event_listeners)

        for cb in list(self._event_listeners):
            # noinspection PyBroadException
            try:
                cb(event)
            except:
                # Don't let exceptions from callbacks kill our thread of execution
                logger.exception("Event callback resulted in unhandled exception")
678024
function handleEvent(cmd, context, filename, callback) {
  var event = JSON.parse(cmd)
  eventline.route(event)
}
1025605
async def _trigger_event(self, event, *args, **kwargs):
        """"""
        run_async = kwargs.pop('run_async', False)
        ret = None
        if event in self.handlers:
            if asyncio.iscoroutinefunction(self.handlers[event]) is True:
                if run_async:
                    return self.start_background_task(self.handlers[event],
                                                      *args)
                else:
                    try:
                        ret = await self.handlers[event](*args)
                    except asyncio.CancelledError:  # pragma: no cover
                        pass
                    except:
                        self.logger.exception(event + ' async handler error')
                        if event == 'connect':
                            # if connect handler raised error we reject the
                            # connection
                            return False
            else:
                if run_async:
                    async def async_handler():
                        return self.handlers[event](*args)

                    return self.start_background_task(async_handler)
                else:
                    try:
                        ret = self.handlers[event](*args)
                    except:
                        self.logger.exception(event + ' handler error')
                        if event == 'connect':
                            # if connect handler raised error we reject the
                            # connection
                            return False
        return ret
1025994
def process_event(self, event_id):
    """"""
    with db.session.begin_nested():
        event = Event.query.get(event_id)
        event._celery_task = self  # internal binding to a Celery task
        event.receiver.run(event)  # call run directly to avoid circular calls
        flag_modified(event, 'response')
        flag_modified(event, 'response_headers')
        db.session.add(event)
    db.session.commit()
252683
def event_handler(self):
        """"""

        if not self._notify_queue:
            LOG.error('event_handler: no notification queue for %s',
                      self._service_name)
            return

        LOG.debug('calling event handler for %s', self)
        self.start()
        self.wait()
1105831
function proxyEvent (emitter, event, optionalCallback) {
    emitter.on(event, function () {
      if (optionalCallback) {
        optionalCallback.apply(client, arguments)
      }
      client.emit(event)
    })
  }
474976
async def trigger(self, event, kwargs):
        
        await self._queue.put((event, kwargs))
        self._resume_processing.set()
619857
def push_event(self, event_name, event_type, block_id):
        """"""
        self._db.rpush(event_name, dict(type=event_type, id=block_id))
294358
public void invokeNodeRequest (String nodeName, NodeRequest request,
        InvocationService.ResultListener listener)
    {
        invokeNodeRequest(nodeName, flattenRequest(request), listener);
    }