- def makemsgtimer(self):
- self.msgtimer = MyTimer(3, self._popmsg)
+ if cmd is not None:
+ if self.conn.bytessent+len(cmd) > self.conn.recvq: # If it's too long
+ if len(cmd) > self.conn.recvq: # Is the command itself somehow over max length???
+ self._msgtimer.start()
+ raise ValueError('Somehow a command that was too long made it into the message queue. Uhoh!', cmd)
+ # Discard the message.
+ self.msgqueue.appendleft(cmd) # Phew, we've just sent too much recently. Put it (back) on the (primary) queue.
+ else:
+ self.conn.send(cmd)
+
+ self._msgtimer.start()
+
+ def _makemsgtimer(self):
+ self._msgtimer = MyTimer(3, self._popmsg)