Get the event loop.

        This may be None or an instance of EventLoop.
491646
def get_event_loop(self):
        
        if (self._event_loop is None and
            threading.current_thread().name == 'MainThread'):
            self._event_loop = self.new_event_loop()
        return self._event_loop
1074549
def wait_for_event(self, event, timeout=10):
        
        return self.__handler.wait_for_event(event, timeout=timeout)
1341597
def events(self):
        ''''''
        ret = []
        while True:
            e = self.poll()
            if e is None:
                break
            ret.append(e)
        return ret
820535
protected function buildEventLoop() {
        $eventLoop = $this->eventHandlerFactory->getHandler('Loop')->getInlineCode()
            . $this->buildControlHandlerLoop()
            . $this->eventHandlerFactory->getHandler('Custom')->getInlineCode()
            . $this->eventHandlerFactory->getHandler('Timer')->getInlineCode();

        $result = '';
        if (!empty($eventLoop)) {
            $result = '    while(True) {' . PHP_EOL
                    . $eventLoop
                    . '        yield;' . PHP_EOL
                    . '    }';
        }
        return $result;
    }
1054201
List<EventInfo> getEvents() {
        synchronized (events) {
            List<EventInfo> result = new ArrayList<>(events.size());
            for (ListIterator<EventInfo> iterator = events.listIterator(events.size()); iterator.hasPrevious();) {
                result.add(iterator.previous());
            }
            return result;
        }
    }
250864
protected function forLoop()
    {
        $start = intval((string)$this->getRequiredTemplateVariable('LoopStart'));
        $end = intval((string)$this->getRequiredTemplateVariable('LoopEnd'));
        $items = array();

    	if ($start > $end) {
            for ($i = $start; $i >= $end; $i--)
                $items[] = array('ForIndex' => $i);
        } else {
            for ($i = $start; $i <= $end; $i++)
                $items[] = array('ForIndex' => $i);
        }

        $this->templateVars['TotalRecords'] = count($items);
        return $items;
    }
590581
def _event_loop(self):
        
        while True:
            orig_line = self.conn.iqueue.get()
            log.debug('<< ' + orig_line)
            line = u(orig_line, errors='replace').strip()
            err_msg = False
            try:
                message = Message(line)
            except ValueError:
                err_msg = True
            if err_msg or message.erroneous:
                log.error("Received a line that can't be parsed: \"%s\"" % orig_line)
                continue
            if message.command == ERR_NICKNAMEINUSE:
                self.set_nick(IRC.randomize_nick(self.nick))
            elif message.command == RPL_CONNECTED:
                for channel in self.channels:
                    self.join(channel)
            self._handle(message)
1110439
def _check_events(tk):
    """"""

    used = False
    try:
        # Process all enqueued events, then exit.
        while True:
            try:
                # Get an event request from the queue.
                method, args, kwargs, response_queue = tk.tk._event_queue.get_nowait()
            except queue.Empty:
                # No more events to process.
                break
            else:
                # Call the event with the given arguments, and then return
                # the result back to the caller via the response queue.
                used = True
                if tk.tk._debug >= 2:
                    print('Calling event from main thread:', method.__name__, args, kwargs)
                try:
                    response_queue.put((False, method(*args, **kwargs)))
                except SystemExit:
                    raise  # Raises original SystemExit
                except Exception:
                    # Calling the event caused an exception; return the
                    # exception back to the caller so that it can be raised
                    # in the caller's thread.
                    from sys import exc_info  # Python 2 requirement
                    ex_type, ex_value, ex_tb = exc_info()
                    response_queue.put((True, (ex_type, ex_value, ex_tb)))
    finally:
        # Schedule to check again. If we just processed an event, check
        # immediately; if we didn't, check later.
        if used:
            tk.after_idle(_check_events, tk)
        else:
            tk.after(tk.tk._check_period, _check_events, tk)
770004
def get_event(self, client, check):
        
        data = self._request('GET', '/events/{}/{}'.format(client, check))
        return data.json()
1239612
def _get_loop(self, *args: typing.Any, **kwargs: typing.Any) -> typing.Optional[asyncio.AbstractEventLoop]:
        """"""
        if callable(self.loop_getter):
            if self.loop_getter_need_context:
                return self.loop_getter(*args, **kwargs)  # pylint: disable=not-callable
            return self.loop_getter()  # pylint: disable=not-callable
        return self.loop_getter
287129
private EventLoopPool getOrCreateEventLoopPool(EventLoop eventLoop) {
        final EventLoopPool pool = eventLoopPools.get(eventLoop);
        if (pool != null) {
            return pool;
        }
        return eventLoopPools.computeIfAbsent(eventLoop, e -> new EventLoopPool());
    }
1170950
def get_loop(self, *args, **kwargs):  # type: (typing.Any, typing.Any) -> asyncio.AbstractEventLoop
        """"""
        if callable(self.loop_getter):
            if self.loop_getter_need_context:
                return self.loop_getter(*args, **kwargs)  # pylint: disable=not-callable
            return self.loop_getter()  # pylint: disable=not-callable
        return self.loop_getter
258403
def main_loop(self, timeout=None):
        
        if self.trigger_event.wait(timeout):
            try:
                self.func()
            except Exception as e:
                self.logger.warning("Got an exception running {func}: {e}".format(func=self.func, e=str(e)))
            finally:
                self.trigger_event.clear()
1280869
def get_events(self):
        
        res = self.con.get('_events', wait=False)
        logger.debug("Got events from %s: %s", self.name, res)
        return unserialize(res, True)
90891
function _loop(i) {
				var eventName = eventNames[i];
				var actionGroup = instructions[eventName];

				ws.addEventListener(eventName, function (res) {

					processActionGroup({ res: res, actionGroup: actionGroup });

					// TODO handle sending messages
				});
			}
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
1347883
def current(cls):
        
        try:
            return _tls.loop
        except AttributeError:
            # create loop only for main thread
            if threading.current_thread().name == 'MainThread':
                _tls.loop = cls()
                return _tls.loop
            raise RuntimeError('there is no event loop created in the current thread')