3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 19:52:53 +01:00

main: raise connect timeout, run initVars on connect and not disconnect

This commit is contained in:
James Lu 2015-08-03 04:41:00 -07:00
parent 58e84a654c
commit 120f6fb7f0

View File

@ -77,10 +77,11 @@ class Irc():
port = self.serverdata["port"]
while True:
log.info("Connecting to network %r on %s:%s", self.name, ip, port)
self.initVars()
try:
# Initial connection timeout is a lot smaller than the timeout after
# we've connected; this is intentional.
self.socket = socket.create_connection((ip, port), timeout=1)
self.socket = socket.create_connection((ip, port), timeout=self.pingfreq)
self.socket.setblocking(0)
self.socket.settimeout(self.pingtimeout)
self.proto.connect(self)
@ -110,8 +111,6 @@ class Irc():
except: # Socket timed out during creation; ignore
pass
self.callHooks([None, 'PYLINK_DISCONNECT', {}])
# Reset all our variables - this is important!
self.initVars()
def run(self):
buf = b""