Example #1
0
 def writeout(self):
     # Write to socket/server
     while True:
         try:
             (priority, sent, line) = self.output.get(True, 1)
         except Empty:
             if self.quitting:
                 break
             else:
                 continue
         try:
             while self.last + Config.getfloat("Connection", "antiflood") * (1 + (len(line) > 300) + (priority > 10)) >= time.time():
                 time.sleep(0.5)
             # Warn admins if the wait is too long
             if time.time() > sent + Config.getint("Connection", "maxdelay"):
                 if time.time() > self.wait_warned + 300:
                     self.wait_warned = time.time()
                     adminmsg("Message output message delay is too long: %.1f seconds" % (time.time() - sent))
             self.sock.send(encode(line) + CRLF)
             self.last = time.time()
             print "%s >>> %s" % (time.asctime(),encode(line),)
             self.output.task_done()
             if line[:4].upper() == "QUIT":
                 break
         except socket.error as exc:
             raise Reboot(exc)
Example #2
0
 def write(self, line, priority=10):
     # Write to output queue
     self.output.put((priority, time.time(), line))
     # Warn admins if the queue is too long
     if self.output.qsize() > Config.getint("Connection", "maxqueue"):
         if time.time() > self.queue_warned + 300:
             self.queue_warned = time.time()
             adminmsg("Message output queue length is too long: %s messages" % self.output.qsize())