def pull(self):
        """This coroutine handles the server connection, does a basic parse on
        the received messages and put them in a queue named events.
        The controllers pull method will take the messages from that queue.
        """
        self.sock = sockets.Socket()
        self.sock.settimeout(self.sock_timo)
        yield events.AddCoro(self.monitor)
        while not self.connected:
            try:
                addr = self.server.split(':')
                if len(addr) < 2:
                    addr.append(6667)
                else:
                    addr[1] = int(addr[1])
                yield self.events.put(('', 'CONNECTING', ''), timeout=self.sock_timo)
                yield self.sock.connect(tuple(addr))
                self.connected = True
            except events.OperationTimeout, e:
                yield self.events.put(('', 'CONNECT_TIMEOUT', str(e)), timeout=self.sock_timo)
                yield events.Sleep(self.reconnect_interval)

        yield self.events.put_nowait(('', 'CONNECTED', ''))
        fobj = self.sock.makefile()
        while 1:
            try:
                line = yield fobj.readline(8192)
                prefix, command, params = parsemsg(line.rstrip('\r\n'))
                if command in numeric_events:
                    command = numeric_events[command].upper()
                print 'PULLME:', (prefix, command, params)
                yield self.events.put((prefix, command, params), timeout=self.sock_timo)
            except Exception, e:
                yield self.events.put(('', 'ERROR', str(e)), timeout=self.sock_timo)
                break
def pull ( self ) : self . sock = sockets . Socket ( ) self . sock . settimeout ( self . sock_timo ) yield events . AddCoro ( self . monitor ) while not self . connected : try : addr = self . server . split ( ':' ) if len ( addr ) < 2 : addr . append ( 6667 ) else : addr [ 1 ] = int ( addr [ 1 ] ) yield self . events . put ( ( '' , 'CONNECTING' , '' ) , timeout = self . sock_timo ) yield self . sock . connect ( tuple ( addr ) ) self . connected = True except events . OperationTimeout , e : yield self . events . put ( ( '' , 'CONNECT_TIMEOUT' , str ( e ) ) , timeout = self . sock_timo ) yield events . Sleep ( self . reconnect_interval ) yield self . events . put_nowait ( ( '' , 'CONNECTED' , '' ) ) fobj = self . sock . makefile ( ) while 1 : try : line = yield fobj . readline ( 8192 ) prefix , command , params = parsemsg ( line . rstrip ( '\r\n' ) ) if command in numeric_events : command = numeric_events [ command ] . upper ( ) print 'PULLME:' , ( prefix , command , params ) yield self . events . put ( ( prefix , command , params ) , timeout = self . sock_timo ) except Exception , e : yield self . events . put ( ( '' , 'ERROR' , str ( e ) ) , timeout = self . sock_timo ) break
This coroutine handles the server connection, does a basic parse on
        the received messages and put them in a queue named events.
        The controllers pull method will take the messages from that queue.