mirror of https://github.com/Mikaela/Limnoria.git
Remove a driver from the list of dead drivers after it has been restarted. Closes GH-1165.
This commit is contained in:
parent
a8be36051f
commit
6d4ea07b72
|
@ -38,7 +38,7 @@ from .. import conf, ircmsgs, log as supylog, utils
|
||||||
from ..utils import minisix
|
from ..utils import minisix
|
||||||
|
|
||||||
_drivers = {}
|
_drivers = {}
|
||||||
_deadDrivers = []
|
_deadDrivers = set()
|
||||||
_newDrivers = []
|
_newDrivers = []
|
||||||
|
|
||||||
class IrcDriver(object):
|
class IrcDriver(object):
|
||||||
|
@ -94,7 +94,7 @@ def add(name, driver):
|
||||||
|
|
||||||
def remove(name):
|
def remove(name):
|
||||||
"""Removes the driver with the given name from the loop."""
|
"""Removes the driver with the given name from the loop."""
|
||||||
_deadDrivers.append(name)
|
_deadDrivers.add(name)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""Runs the whole driver loop."""
|
"""Runs the whole driver loop."""
|
||||||
|
@ -104,7 +104,7 @@ def run():
|
||||||
driver.run()
|
driver.run()
|
||||||
except:
|
except:
|
||||||
log.exception('Uncaught exception in in drivers.run:')
|
log.exception('Uncaught exception in in drivers.run:')
|
||||||
_deadDrivers.append(name)
|
_deadDrivers.add(name)
|
||||||
for name in _deadDrivers:
|
for name in _deadDrivers:
|
||||||
try:
|
try:
|
||||||
driver = _drivers[name]
|
driver = _drivers[name]
|
||||||
|
@ -119,6 +119,7 @@ def run():
|
||||||
while _newDrivers:
|
while _newDrivers:
|
||||||
(name, driver) = _newDrivers.pop()
|
(name, driver) = _newDrivers.pop()
|
||||||
log.debug('Adding new driver %s.', name)
|
log.debug('Adding new driver %s.', name)
|
||||||
|
_deadDrivers.discard(name)
|
||||||
if name in _drivers:
|
if name in _drivers:
|
||||||
log.warning('Driver %s already added, killing it.', name)
|
log.warning('Driver %s already added, killing it.', name)
|
||||||
_drivers[name].die()
|
_drivers[name].die()
|
||||||
|
|
Loading…
Reference in New Issue