summaryrefslogtreecommitdiff
path: root/irc.py
diff options
context:
space:
mode:
authorBrian Sherson <caretaker82@euclid.shersonb.net>2013-09-01 22:12:55 -0700
committerBrian Sherson <caretaker82@euclid.shersonb.net>2013-09-01 22:12:55 -0700
commit97d3076e651c36dbcfe4fe478762e63e83a3848b (patch)
tree9baa0d06dc4da2c89a3a2f9aadd9b86fcc764b70 /irc.py
parent2011bf9bbd042bba4a649f9e52a52c1149ff09c8 (diff)
Just another update
Diffstat (limited to 'irc.py')
-rw-r--r--irc.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/irc.py b/irc.py
index d8d564e..4718187 100644
--- a/irc.py
+++ b/irc.py
@@ -152,6 +152,13 @@ class Connection(Thread):
else:
self.connection = socket.socket(socket.AF_INET6 if self.ipv6 else socket.AF_INET, socket.SOCK_STREAM)
self.connection.connect((self.server, self.port, 0, 0) if self.ipv6 else (self.server, self.port))
+ except socket.error:
+ with self.loglock:
+ exc, excmsg, tb = sys.exc_info()
+ timestamp = reduce(lambda x, y: x+":"+y, [str(t).rjust(2, "0") for t in time.localtime()[0:6]])
+ print >>self.log, "%(timestamp)s *** Connection to %(server)s:%(port)s failed: %(excmsg)s." % vars()
+ self.log.flush()
+ else:
self.connected = True
self.connection.settimeout(self.timeout)
@@ -172,17 +179,13 @@ class Connection(Thread):
print >>self.log, "%(timestamp)s *** Connection to %(server)s:%(port)s established." % vars()
self.log.flush()
break
- except socket.error:
- with self.loglock:
- exc, excmsg, tb = sys.exc_info()
- timestamp = reduce(lambda x, y: x+":"+y, [str(t).rjust(2, "0") for t in time.localtime()[0:6]])
- print >>self.log, "%(timestamp)s *** Connection to %(server)s:%(port)s failed: %(excmsg)s." % vars()
- self.log.flush()
if self.quitexpected:
sys.exit()
if attempt < self.maxretries or self.maxretries == -1:
time.sleep(self.retrysleep)
+ if self.quitexpected:
+ sys.exit()
attempt += 1
else:
with self.loglock: