Wait for an event on any channel.
501475
def drain_events(self, allowed_methods=None, timeout=None):
        """"""
        return self.wait_multi(self.channels.values(), timeout=timeout)
924586
public Channel onFindChannel(FindChannelEvent event) {
        Assert.notNull(event);
        Long channelId = event.getChannelId();
        Long pipelineId = event.getPipelineId();
        Channel channel = null;
        if (channelId != null) {
            channel = channelService.findById(channelId);
        } else {
            Assert.notNull(pipelineId);
            channel = channelService.findByPipelineId(pipelineId);
        }

        return channel;
    }
548606
private void waitForChannelResubscription(final Map<Integer, ChannelCallbackHandler> oldChannelIdSymbolMap)
			throws BitfinexClientException, InterruptedException {
		
		final Stopwatch stopwatch = Stopwatch.createStarted();
		final long MAX_WAIT_TIME_IN_MS = TimeUnit.MINUTES.toMillis(3);
		logger.info("Waiting for streams to resubscribe (max wait time {} msec)", MAX_WAIT_TIME_IN_MS);

		synchronized (channelIdToHandlerMap) {
			
			while(channelIdToHandlerMap.size() != oldChannelIdSymbolMap.size()) {
				
				if(stopwatch.elapsed(TimeUnit.MILLISECONDS) > MAX_WAIT_TIME_IN_MS) {
					// Raise BitfinexClientException
					handleResubscribeFailed(oldChannelIdSymbolMap);
				}
				
				channelIdToHandlerMap.wait(500);
			}
			
		}
	}
757442
private static void waitForChannelClosure(Channel channel, long timoutInMs) {
        final long start = System.currentTimeMillis();
        final long until = start + timoutInMs;
        try {
            while (!channel.isClosed() && System.currentTimeMillis() < until) {
                Thread.sleep(CLOSURE_WAIT_INTERVAL);
            }
            logger.trace("Time waited for channel closure: " + (System.currentTimeMillis() - start));
        } catch (InterruptedException e) {
            logger.trace("Interrupted", e);
        }
        if (!channel.isClosed()) {
            logger.trace("Channel not closed in timely manner!");
        }
    }
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
379334
def wait_multi(self, channels, allowed_methods=None, timeout=None):
        """"""
        chanmap = dict((chan.channel_id, chan) for chan in channels)
        chanid, method_sig, args, content = self._wait_multiple(
                chanmap.keys(), allowed_methods, timeout=timeout)

        channel = chanmap[chanid]

        if content \
        and channel.auto_decode \
        and hasattr(content, 'content_encoding'):
            try:
                content.body = content.body.decode(content.content_encoding)
            except Exception:
                pass

        amqp_method = channel._METHOD_MAP.get(method_sig, None)

        if amqp_method is None:
            raise Exception('Unknown AMQP method (%d, %d)' % method_sig)

        if content is None:
            return amqp_method(channel, args)
        else:
            return amqp_method(channel, args, content)
1110528
def _wait_for_result(self):
        """"""
        basetime = 0.018 if self._low_res else 0.128
        sleep(basetime * (self._mtreg / 69.0) + self._delay)
265411
def wait(self, timeout=None):
        """"""
        # Optimization for the case the Event is already set.
        if self._flag:
            return True
        hub = get_hub()
        try:
            with switch_back(timeout, lock=self._lock) as switcher:
                with self._lock:
                    # Need to check the flag again, now under the lock.
                    if self._flag:
                        return True
                    # Allow other fibers to wake us up via callback in set().
                    # The callback goes to switcher.switch directly() instead of
                    # __call__(), because the latter would try to lock our lock
                    # which is already held when callbacks are run by set().
                    handle = add_callback(self, switcher.switch)
                # See note in Lock.acquire() why we can call to hub.switch()
                # outside the lock.
                hub.switch()
        except BaseException as e:
            with self._lock:
                remove_callback(self, handle)
            if e is switcher.timeout:
                return False
            raise
        return True
35100
async def wait_for_send(self, event, *, until=None):
        '''
        
        '''
        while True:
            if until:
                r = until()
                if r:
                    return r
            waiter = self.scheduler.send(event)
            if waiter is None:
                break
            await waiter
50245
function listen(channel, onChange) {
        var pin = getPinForCurrentMode(channel);

        if (!exportedInputPins[pin] && !exportedOutputPins[pin]) {
            throw new Error('Channel %d has not been exported', channel);
        }

        debug('listen for pin %d', pin);
        var poller = new Epoll(function(err, innerfd, events) {
            if (err) throw err
            clearInterrupt(innerfd);
            onChange(channel);
        });

        var fd = fs.openSync(PATH + '/gpio' + pin + '/value', 'r+');
        clearInterrupt(fd);
        poller.add(fd, Epoll.EPOLLPRI);
        // Append ready-to-use remove function
        pollers[pin] = function() {
            poller.remove(fd).close();
        }
    }
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
601727
def listen(self):
        
        with Consumer(self.connection, queues=self.queue, on_message=self.on_message,
                      auto_declare=False):
            for _ in eventloop(self.connection, timeout=1, ignore_timeouts=True):
                    pass
728898
def drain_events(self, timeout=None):
        """"""
        chanmap = self.channels
        chanid, method_sig, args, content = self._wait_multiple(
            chanmap, None, timeout=timeout,
        )

        channel = chanmap[chanid]

        if (content and
                channel.auto_encode_decode and
                hasattr(content, 'content_encoding')):
            try:
                content.body = content.body.decode(content.content_encoding)
            except Exception:
                pass

        amqp_method = (self._method_override.get(method_sig) or
                       channel._METHOD_MAP.get(method_sig, None))

        if amqp_method is None:
            raise AMQPNotImplementedError(
                'Unknown AMQP method {0!r}'.format(method_sig))

        if content is None:
            return amqp_method(channel, args)
        else:
            return amqp_method(channel, args, content)
1148899
def trigger(self, event: str, *args: T.Any, **kw: T.Any) -> bool:
        """"""

        callbacks = list(self._events.get(event, []))
        if not callbacks:
            return False

        for callback in callbacks:
            callback(*args, **kw)
        return True
1318063
def subscribe(self, client, channel_name):
        """"""
        if channel_name not in self.channels:
            self.channels[channel_name] = channel = Channel(channel_name)
            channel.start()

        self.channels[channel_name].subscribe(client)
1366921
def wait_for_newchannel(
        raiden: 'RaidenService',
        payment_network_id: PaymentNetworkID,
        token_address: TokenAddress,
        partner_address: Address,
        retry_timeout: float,
) -> None:
    
    channel_state = views.get_channelstate_for(
        views.state_from_raiden(raiden),
        payment_network_id,
        token_address,
        partner_address,
    )

    while channel_state is None:
        gevent.sleep(retry_timeout)
        channel_state = views.get_channelstate_for(
            views.state_from_raiden(raiden),
            payment_network_id,
            token_address,
            partner_address,
        )
677484
def wait_for_exists(self, timeout=0, *args, **selectors):
        
        return self.device(**selectors).wait.exists(timeout=timeout)