mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Fixed bug in socketDrivers and made it less likely to happen with a fix in drivers.
This commit is contained in:
parent
25aca81c9a
commit
f06a552b73
@ -69,7 +69,7 @@ class IrcDriver(object):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.__class__.__name__
|
return repr(self)
|
||||||
|
|
||||||
|
|
||||||
class Interactive(IrcDriver):
|
class Interactive(IrcDriver):
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
Contains simple socket drivers. Asyncore bugged (haha, pun!) me.
|
Contains simple socket drivers. Asyncore bugged (haha, pun!) me.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
from fix import *
|
from fix import *
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@ -52,8 +54,8 @@ class SocketDriver(drivers.IrcDriver):
|
|||||||
global instances
|
global instances
|
||||||
instances += 1
|
instances += 1
|
||||||
conf.poll = originalPoll / instances
|
conf.poll = originalPoll / instances
|
||||||
drivers.IrcDriver.__init__(self)
|
|
||||||
self.server = (server, port)
|
self.server = (server, port)
|
||||||
|
drivers.IrcDriver.__init__(self) # Must come after server is set.
|
||||||
self.irc = irc
|
self.irc = irc
|
||||||
self.irc.driver = self
|
self.irc.driver = self
|
||||||
self.inbuffer = ''
|
self.inbuffer = ''
|
||||||
@ -71,8 +73,14 @@ class SocketDriver(drivers.IrcDriver):
|
|||||||
del msgs[-1]
|
del msgs[-1]
|
||||||
self.outbuffer += ''.join(map(str, msgs))
|
self.outbuffer += ''.join(map(str, msgs))
|
||||||
if self.outbuffer:
|
if self.outbuffer:
|
||||||
|
try:
|
||||||
sent = self.conn.send(self.outbuffer)
|
sent = self.conn.send(self.outbuffer)
|
||||||
self.outbuffer = self.outbuffer[sent:]
|
self.outbuffer = self.outbuffer[sent:]
|
||||||
|
except socket.error, e:
|
||||||
|
# (11, 'Resource temporarily unavailable') raised if connect
|
||||||
|
# hasn't finished yet.
|
||||||
|
if e.args[0] != 11:
|
||||||
|
raise
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
#debug.methodNamePrintf(self, 'run')
|
#debug.methodNamePrintf(self, 'run')
|
||||||
@ -97,6 +105,8 @@ class SocketDriver(drivers.IrcDriver):
|
|||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
pass
|
pass
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
|
# Same as with _sendIfMsgs.
|
||||||
|
if e.args[0] != 11:
|
||||||
s = 'Disconnect from %s: %s' % (self.server, e.args[1])
|
s = 'Disconnect from %s: %s' % (self.server, e.args[1])
|
||||||
debug.msg(s, 'normal')
|
debug.msg(s, 'normal')
|
||||||
self.die()
|
self.die()
|
||||||
@ -111,11 +121,12 @@ class SocketDriver(drivers.IrcDriver):
|
|||||||
self.reconnectWaitsIndex += 1
|
self.reconnectWaitsIndex += 1
|
||||||
try:
|
try:
|
||||||
self.conn.connect(self.server)
|
self.conn.connect(self.server)
|
||||||
self.connected = True
|
|
||||||
self.reconnectWaitPeriodsIndex = 0
|
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
|
if e.args[0] != 115:
|
||||||
debug.msg('Error connecting to %s: %s' % (self.server, e))
|
debug.msg('Error connecting to %s: %s' % (self.server, e))
|
||||||
self.die()
|
self.die()
|
||||||
|
self.connected = True
|
||||||
|
self.reconnectWaitPeriodsIndex = 0
|
||||||
|
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
@ -129,6 +140,9 @@ class SocketDriver(drivers.IrcDriver):
|
|||||||
'normal')
|
'normal')
|
||||||
schedule.addEvent(self.reconnect, when)
|
schedule.addEvent(self.reconnect, when)
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
return '%s%s' % (self.__class__.__name__, self.server)
|
||||||
|
|
||||||
|
|
||||||
Driver = SocketDriver
|
Driver = SocketDriver
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user