:category: Asynchronous Methods
 Asynchronously request to create an event and return a
 PredictionIO::AsyncResponse object immediately.

 Corresponding REST API method: POST /events.json

 See also #create_event.
433553
def acreate_event(event, entity_type, entity_id, optional = {})
      h = optional.with_indifferent_access
      h.key?('eventTime') || h['eventTime'] = DateTime.now.iso8601
      h['event'] = event
      h['entityType'] = entity_type
      h['entityId'] = entity_id
      @http.apost(PredictionIO::AsyncRequest.new(event_path_with_main_params(h), h.except(:channel).to_json))
    end
679897
async def create_post_request(self, method: str, params: Dict = None):
        
        if params is None:
            params = {}
        headers = {"Content-Type": "application/json"}
        payload = {
            "method": method,
            "params": [params],
            "id": next(self.idgen),
            "version": "1.0",
        }

        if self.debug > 1:
            _LOGGER.debug("> POST %s with body: %s", self.guide_endpoint, payload)

        async with aiohttp.ClientSession(headers=headers) as session:
            res = await session.post(self.guide_endpoint, json=payload, headers=headers)
            if self.debug > 1:
                _LOGGER.debug("Received %s: %s" % (res.status_code, res.text))
            if res.status != 200:
                raise SongpalException(
                    "Got a non-ok (status %s) response for %s" % (res.status, method),
                    error=await res.json()["error"],
                )

            res = await res.json()

        # TODO handle exceptions from POST? This used to raise SongpalException
        #      on requests.RequestException (Unable to get APIs).

        if "error" in res:
            raise SongpalException("Got an error for %s" % method, error=res["error"])

        if self.debug > 1:
            _LOGGER.debug("Got %s: %s", method, pf(res))

        return res
874506
def broadcast(event, benchmark)
      serialized = RequestSerializer.new(event[:request]).serialize.
        merge(benchmark.stats).
        merge(event.slice(:response, :metadata))
      if ActiveSupport::Notifications.notifier.listening?("coach.request")
        ActiveSupport::Deprecation.warn("The 'coach.request' event has been renamed " \
          "to 'request.coach' and the old name will be removed in a future version.")
        ActiveSupport::Notifications.publish("coach.request", serialized)
      end
      ActiveSupport::Notifications.publish("request.coach", serialized)
    end
754347
def _make_request(self, method, params):
        
        if self.blocked_until is not None and \
                datetime.datetime.utcnow() < self.blocked_until:
            raise SlackError("Too many requests - wait until {0}" \
                    .format(self.blocked_until))

        url = "%s/%s" % (SlackClient.BASE_URL, method)
        params['token'] = self.token
        response = requests.post(url, data=params, verify=self.verify)

        if response.status_code == 429:
            # Too many requests
            retry_after = int(response.headers.get('retry-after', '1'))
            self.blocked_until = datetime.datetime.utcnow() + \
                    datetime.timedelta(seconds=retry_after)
            raise SlackError("Too many requests - retry after {0} second(s)" \
                    .format(retry_after))

        result = response.json()
        if not result['ok']:
            raise SlackError(result['error'])
        return result
867810
function createAsync() {
  var
    wired = new Async,
    wire = render.bind(wired),
    chunksReceiver
  ;
  wired.update = function () {
    this.callback = chunksReceiver;
    return chunks.apply(this, arguments);
  };
  return function (callback) {
    chunksReceiver = callback || String;
    return wire;
  };
}
1229740
def asynchronous(method):
    
    def _async(*args, **kwargs):
        GObject.idle_add(method, *args, **kwargs)
    return _async
873558
def new_event(self, subject=None):
        
        return self.event_constructor(parent=self, subject=subject,
                                      calendar_id=self.calendar_id)
1303899
def create_event_subscription(self, url):
        
        params = {'callbackUrl': url}
        response = self._do_request('POST', '/v2/eventSubscriptions', params)
        return response.json()
156961
def event_emitter(cls_=None, *, events=('*', )):
    

    # create a dictionary from items in the 'events' parameter and with empty
    # lists as values
    event_dict = dict.fromkeys(events, [])

    # if '*' was in the events tuple - then pop it out of the event_dict
    # and store the fact that we may allow any event name to be added to the
    # event emitter.
    allow_any_eventname = event_dict.pop('*', False) == []

    def _event_emitter(cls):

        def on(self, name, callback):
            """
            Add a callback to the event named 'name'. Returns the object for
            chained 'on' calls.
            """
            if not (callable(callback) or isawaitable(callback)):
                raise ValueError("Callback not callable: %r" % callback)

            try:
                event_dict[name].append(callback)
            except KeyError:
                if allow_any_eventname:
                    event_dict[name] = [callback]
                else:
                    msg = "Event Emitter has no event {!r}".format(name)
                    raise KeyError(msg)

            return self

        async def emit(self, name):
            """
            Coroutine which executes each of the callbacks added to the event
            identified by 'name'
            """
            for cb in event_dict[name]:
                if isawaitable(cb):
                    await cb
                else:
                    cb()

        cls.on = on
        cls.emit = emit

        return cls

    if cls_ is None:
        return _event_emitter
    else:
        return _event_emitter(cls_)
952844
def fetch_events_async(issues)
      i       = 0
      threads = []

      issues.each_slice(MAX_THREAD_NUMBER) do |issues_slice|
        issues_slice.each do |issue|
          threads << Thread.new do
            issue["events"] = []
            iterate_pages(@client, "issue_events", issue["number"]) do |new_event|
              issue["events"].concat(new_event)
            end
            issue["events"] = issue["events"].map { |event| stringify_keys_deep(event.to_hash) }
            print_in_same_line("Fetching events for issues and PR: #{i + 1}/#{issues.count}")
            i += 1
          end
        end
        threads.each(&:join)
        threads = []
      end

      # to clear line from prev print
      print_empty_line

      Helper.log.info "Fetching events for issues and PR: #{i}"
    end
95598
def create_event(*args)
      raise "EventCampaign needs to be saved before Event creation" if self.id.nil?

      (args[0]).merge!(:campaign_id => self.id)

      event = ActionKitApi::Event.new(*args)
    end
672153
def new_event(event):
    
    op_name = event.EventType.DESCRIPTOR.values_by_number[event.type].name
    if op_name == 'PUT':
        cls = PutEvent
    elif op_name == 'DELETE':
        cls = DeleteEvent
    else:
        raise Exception('Invalid op_name')

    return cls(event)
1073728
def post_event(self, event):
        

        url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, self.api_version,
                                                       self.project_id,
                                                       event.event_collection)
        headers = utilities.headers(self.write_key)
        payload = event.to_json()
        response = self.fulfill(HTTPMethods.POST, url, data=payload, headers=headers, timeout=self.post_timeout)
        self._error_handling(response)
247578
def create(*events):
    
    or_event = threading.Event()

    def changed():
        if any([event.is_set() for event in events]):
            or_event.set()
        else:
            or_event.clear()

    for e in events:
        orify(e, changed)

    changed()
    return or_event
377011
async def consume_events(self):
        ''' '''
        # begin by making sure the channel is created
        await self.create_channel()
        # get cursor method
        def create_cursor():
            now = datetime.datetime.utcnow()
            dummy_id = ObjectId.from_datetime(now)
            return self._collection.find({'_id': {'$gte': dummy_id}}, cursor_type=CursorType.TAILABLE_AWAIT)
        # get cursor and start the loop
        cursor = create_cursor()
        while self.active:
            if cursor.alive:
                if (await cursor.fetch_next):
                    message = cursor.next_object()
                    event = message['key']
                    data = message['data']
                    logger.debug('event: %s - %s', event, data)
                    for sub in self._subscribers[event]:
                        await sub.deliver({'type': 'event', 'payload': {'name': event, 'data': data}})
            else:
                await asyncio.sleep(0.1)
                cursor = create_cursor()
10091
def post_event(self, client, check):
        
        self._request('POST', '/resolve',
                      data=json.dumps({'client': client, 'check': check}))
        return True
903434
def community_post_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/community/posts.json"
        return self.call(api_path, method="POST", data=data, **kwargs)