mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-26 04:32:51 +01:00
main: raise connect timeout, run initVars on connect and not disconnect
This commit is contained in:
parent
58e84a654c
commit
120f6fb7f0
5
main.py
5
main.py
@ -77,10 +77,11 @@ class Irc():
|
|||||||
port = self.serverdata["port"]
|
port = self.serverdata["port"]
|
||||||
while True:
|
while True:
|
||||||
log.info("Connecting to network %r on %s:%s", self.name, ip, port)
|
log.info("Connecting to network %r on %s:%s", self.name, ip, port)
|
||||||
|
self.initVars()
|
||||||
try:
|
try:
|
||||||
# Initial connection timeout is a lot smaller than the timeout after
|
# Initial connection timeout is a lot smaller than the timeout after
|
||||||
# we've connected; this is intentional.
|
# 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.setblocking(0)
|
||||||
self.socket.settimeout(self.pingtimeout)
|
self.socket.settimeout(self.pingtimeout)
|
||||||
self.proto.connect(self)
|
self.proto.connect(self)
|
||||||
@ -110,8 +111,6 @@ class Irc():
|
|||||||
except: # Socket timed out during creation; ignore
|
except: # Socket timed out during creation; ignore
|
||||||
pass
|
pass
|
||||||
self.callHooks([None, 'PYLINK_DISCONNECT', {}])
|
self.callHooks([None, 'PYLINK_DISCONNECT', {}])
|
||||||
# Reset all our variables - this is important!
|
|
||||||
self.initVars()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
buf = b""
|
buf = b""
|
||||||
|
Loading…
Reference in New Issue
Block a user