Simulate an asynchronous event.
329138
def simulate_async_event():
    """"""
    scc.state = 'executing'
    def async_event(result):
        """All other asynchronous events or function calls
        returned from later steps will wait until this
        callback fires."""
        scc.state = result
        return 'some event result'
    deferred = Deferred()
    reactor.callLater(1, deferred.callback, 'done') # pylint: disable=E1101
    deferred.addCallback(async_event)
    return deferred
1108184
def handle_input(self, event):
        """"""
        self.update_timeval()
        self.events = []
        code = self._get_event_key_code(event)

        if code in self.codes:
            new_code = self.codes[code]
        else:
            new_code = 0
        event_type = self._get_event_type(event)
        value = self._get_key_value(event, event_type)
        scan_event, key_event = self.emulate_press(
            new_code, code, value, self.timeval)

        self.events.append(scan_event)
        self.events.append(key_event)
        # End with a sync marker
        self.events.append(self.sync_marker(self.timeval))
        # We are done
        self.write_to_pipe(self.events)
1028237
def wait(self, timeout=None):
        """"""
        self._event.wait(timeout)
        return self._event.isSet()
1257845
def call(self, method, args={}, retry=False, retry_policy=None,
             ticket=None, **props):
        """"""
        ticket = ticket or uuid()
        reply_q = self.get_reply_queue(ticket)
        self.cast(method, args, declare=[reply_q], reply_to=ticket, **props)
        return self.AsyncResult(ticket, self)
265473
def wait_for_event(event):
    
    f = Future()
    def ready():
        get_event_loop().remove_win32_handle(event)
        f.set_result(None)
    get_event_loop().add_win32_handle(event, ready)
    return f
199103
def wait_event(self, filter: Callable[[T_Event], bool] = None) -> Awaitable[T_Event]:
        """"""
        return wait_event([self], filter)
69984
function simulateEvent(target_object, event_type) {
  if (!exists(target_object)) {
    throw new TypeError('simulateEvent: target object must be defined');
  }

  if (typeof event_type !== 'string') {
    throw new TypeError('simulateEvent: event type must be a string');
  }

  var event = setupEvent(event_type);
  fireEvent(target_object, event, event_type);
}
492228
void deliverAsyncEvent(final EntryEvent<K,V> _event) {
    if (asyncListenerByType.get(_event.getEventType()).isEmpty()) {
      return;
    }
    List<Listener<K,V>> _listeners =
      new ArrayList<Listener<K, V>>(asyncListenerByType.get(_event.getEventType()));
    if (_listeners.isEmpty()) {
      return;
    }
    K key = _event.getKey();
    synchronized (getLockObject(key)) {
      Queue<EntryEvent<K,V>> q = keyQueue.get(key);
      if (q != null) {
        q.add(_event);
        return;
      }
      q = new LinkedList<EntryEvent<K, V>>();
      keyQueue.put(key, q);
    }
    runAllListenersInParallel(_event, _listeners);
  }
621321
async def event_wait(event: asyncio.Event, timeout=None):
    '''
    
    '''
    if timeout is None:
        await event.wait()
        return True

    try:
        await asyncio.wait_for(event.wait(), timeout)
    except asyncio.TimeoutError:
        return False
    return True
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
862272
def join(self, timeout=None):
        """"""
        if not self._started:
            raise RuntimeError('cannot join task before it is started')
        return self._exit_event.wait(timeout)
105905
def probe_async(self, callback):
        """"""

        future = self._loop.launch_coroutine(self._adapter.probe())
        future.add_done_callback(lambda x: self._callback_future(None, x, callback))
24033
def call_async(func):
    """"""

    @wraps(func)
    def wrapper(self, *args, **kw):
        """Wraps instance method to be called on loop thread"""

        def call():
            """Calls function on loop thread"""
            try:
                func(self, *args, **kw)
            except Exception:
                logger.exception(
                    "failed to call async [%r] with [%r] [%r]", func, args, kw
                )

        self.loop.call_soon_threadsafe(call)

    return wrapper
346761
def asynchronous(self, fun, low, user='UNKNOWN', pub=None):
        '''
        
        '''
        async_pub = pub if pub is not None else self._gen_async_pub()

        proc = salt.utils.process.SignalHandlingMultiprocessingProcess(
                target=self._proc_function,
                args=(fun, low, user, async_pub['tag'], async_pub['jid']))
        with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
            # Reset current signals before starting the process in
            # order not to inherit the current signal handlers
            proc.start()
        proc.join()  # MUST join, otherwise we leave zombies all over
        return async_pub
963122
def listen_to_event_updates():
    """"""
    def callback(event):
        print('Event:', event)

    client.create_event_subscription(instance='simulator', on_data=callback)

    sleep(5)
380557
public synchronized <Q extends T> void dispatchAsynchronous(final Q event, final IPostProcessor<Q> pPostProcessor) {

		new Thread(new Runnable() {

			@Override
			public void run() {

				try {

					// delegate dispatch result
					pPostProcessor.done(dispatch(event));

				} catch (DispatchException lEx) {

					// delegate exception handling as well
					pPostProcessor.done(lEx);

				}
			}
		}).start();

	}
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()