From b7cfb40050b3bae753b97891ff76de14105ce74e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 26 Aug 2012 16:20:22 -0400 Subject: [PATCH] A start on server pooling. --- irker.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/irker.py b/irker.py index 503b8b4..de3b80a 100755 --- a/irker.py +++ b/irker.py @@ -68,10 +68,11 @@ class Session(): # expires, then reconnect and resume transmission if the # queue fills up again. if not self.server: - self.server = self.irker.irc.server() + self.server = self.irker.allocate_server(self.servername, + self.port, + self.name()) self.irker.debug(1, "TTL bump (connection) at %s" % time.asctime()) self.last_active = time.time() - self.server.connect(self.servername, self.port, self.name()) elif self.queue.empty(): if time.time() > self.last_active + TTL: self.irker.debug(1, "timing out inactive connection at %s" % time.asctime()) @@ -109,6 +110,11 @@ class Irker: "Debugging information." if self.debuglevel >= level: sys.stderr.write("irker[%d]: %s\n" % (self.debuglevel, errmsg)) + def allocate_server(self, servername, port, nick): + "Allocate a new server instance." + newserver = self.irc.server() + newserver.connect(servername, port, nick) + return newserver def handle(self, line): "Perform a JSON relay request." try: -- 2.26.2