Ejemplo n.º 1
0
    def poll_sockets(self):
        '''
        Uses select to get readable/writable sockets then calls
        read or write on them
        '''
        readable, writable, exceptional = select.select(self.inputs, self.outputs, self.inputs)
        if readable:
            for r in readable:
                # read from r, placing the messages in the given queue
                self.handle_input(r, self.inq)

        if writable and not self.outq.empty():
            for w in writable:
                # write to w with items pulled from the given queue
                self.handle_output(w, self.outq)

        if exceptional:
            for e in exceptional:
                # TODO can we get the error to log as well?
                self.log.error(u'Exceptional socket {0}'.format(e.getpeername()))
                self.inputs.remove(e)
                self.outputs.remove(e)

        # if we lost all our sockets
        if not self.inputs or not self.outputs:
            self.log.error(u'No sockets left to read/write')
            self.connected = False
            # highest priority message that will get client to attempt to reconnect
            self.inq.put(eu.error('No sockets left to read/write from', priority=1))
Ejemplo n.º 2
0
 def error(self, message, priority=3):
     '''
     Send an error event to the network thread
     args:
         message = message about the error
     kwargs:
         priority = how quickly to process the event
     '''
     self.bot.out_event(eu.error(message, priority))
Ejemplo n.º 3
0
 def error(self, message, priority=3):
     '''
     Send an error event to the network thread
     args:
         message = message about the error
     kwargs:
         priority = how quickly to process the event
     '''
     self.bot.out_event(eu.error(message, priority))
Ejemplo n.º 4
0
 def error(self, msg, priority=1):
     '''
     Used to handle disconnection Events from the network
     thread and the irc server itself. Most bot cores
     will run reconnection logic when they get one
     of these
     kwargs:
         priority = how quickly to process the event
     '''
     self.bot.out_event(eu.error(msg, priority))
Ejemplo n.º 5
0
 def error(self, msg, priority=1):
     '''
     Used to handle disconnection Events from the network
     thread and the irc server itself. Most bot cores
     will run reconnection logic when they get one
     of these        
     kwargs:
         priority = how quickly to process the event
     '''
     self.bot.out_event(eu.error(msg, priority))