Let's unschedule ourselves if we are told to die.

This commit is contained in:
Jeremy Fincher 2004-08-30 18:51:56 +00:00
parent d22449d5a0
commit 74b4628d0b

View File

@ -63,6 +63,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
self.inbuffer = '' self.inbuffer = ''
self.outbuffer = '' self.outbuffer = ''
self.zombie = False self.zombie = False
self.scheduled = None
self.connected = False self.connected = False
self.reconnectWaitsIndex = 0 self.reconnectWaitsIndex = 0
self.reconnectWaits = reconnectWaits self.reconnectWaits = reconnectWaits
@ -123,6 +124,7 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
self.reconnect(reset=False, **kwargs) self.reconnect(reset=False, **kwargs)
def reconnect(self, wait=False, reset=True): def reconnect(self, wait=False, reset=True):
self.scheduled = False
if self.connected: if self.connected:
drivers.log.reconnect(self.irc.network) drivers.log.reconnect(self.irc.network)
self.conn.close() self.conn.close()
@ -181,10 +183,12 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
when = time.time() + self.reconnectWaits[self.reconnectWaitsIndex] when = time.time() + self.reconnectWaits[self.reconnectWaitsIndex]
if not world.dying: if not world.dying:
drivers.log.reconnect(self.irc.network, when) drivers.log.reconnect(self.irc.network, when)
schedule.addEvent(self.reconnect, when) self.scheduled = schedule.addEvent(self.reconnect, when)
def die(self): def die(self):
self.zombie = True self.zombie = True
if self.scheduled:
schedule.removeEvent(self.scheduled)
drivers.log.die(self.irc) drivers.log.die(self.irc)
def _reallyDie(self): def _reallyDie(self):