def iter_run(self):
        """
        The actual processing for the main loop is here.

        Running the main loop as a generator (where a iteration is a full
        sched, proactor and timers/timeouts run) is usefull for interleaving
        the main loop with other applications that have a blocking main loop and
        require cogen to run in the same thread.
        """
        self.running = True
        urgent = None
        while self.running and (self.active or self.proactor or self.timeouts or urgent):
            if self.active or urgent:
                op, coro = urgent or self.active.popleft()
                urgent = None
                while True:
                    op, coro = self.process_op(coro.run_op(op, self), coro)
                    if not op and not coro:
                        break

            if (self.proactor_greedy or not self.active) and self.proactor:
                try:
                    urgent = self.proactor.run(timeout = self.next_timer_delta())
                except (OSError, select.error, IOError), exc:
                    if exc[0] != errno.EINTR:
                        raise
                #~ if urgent:print '>urgent:', urgent
            if self.timeouts:
                self.handle_timeouts()
            yield
            # this could had beed a ordinary function and have the run() call
            #this repeatedly but the _urgent_ operation this is usefull (as it
            #saves us needlessly hammering the active coroutines queue with
            #append and pop calls on the same thing
        self.cleanup()
def iter_run ( self ) : self . running = True urgent = None while self . running and ( self . active or self . proactor or self . timeouts or urgent ) : if self . active or urgent : op , coro = urgent or self . active . popleft ( ) urgent = None while True : op , coro = self . process_op ( coro . run_op ( op , self ) , coro ) if not op and not coro : break if ( self . proactor_greedy or not self . active ) and self . proactor : try : urgent = self . proactor . run ( timeout = self . next_timer_delta ( ) ) except ( OSError , select . error , IOError ) , exc : if exc [ 0 ] != errno . EINTR : raise if self . timeouts : self . handle_timeouts ( ) yield self . cleanup ( )
The actual processing for the main loop is here.

        Running the main loop as a generator (where a iteration is a full
        sched, proactor and timers/timeouts run) is usefull for interleaving
        the main loop with other applications that have a blocking main loop and
        require cogen to run in the same thread.