Revert "master/worker_db: add pause_devices and resume_devices"

This reverts commit 3c70bc40a4.
This commit is contained in:
Sebastien Bourdeauducq 2016-06-11 10:11:07 -06:00
parent ca9724f517
commit 44724197c5
1 changed files with 4 additions and 29 deletions

View File

@ -119,9 +119,7 @@ class DeviceError(Exception):
class DeviceManager:
"""Handles creation and destruction of local device drivers and controller
RPC clients."""
def __init__(self, ddb, virtual_devices=None):
if virtual_devices is None:
virtual_devices = dict()
def __init__(self, ddb, virtual_devices=dict()):
self.ddb = ddb
self.virtual_devices = virtual_devices
self.active_devices = OrderedDict()
@ -158,28 +156,6 @@ class DeviceManager:
self.active_devices[name] = dev
return dev
def pause_devices(self):
"""Pauses all active devices, in the opposite order as they were
requested."""
for dev in reversed(list(self.active_devices.values())):
if hasattr(dev.__class__, "pause"):
try:
dev.pause()
except:
logger.warning("Exception when pausing device %r", dev,
exc_info=True)
def resume_devices(self):
"""Resumes all active devices, in the same order as they were
requested."""
for dev in self.active_devices.values():
if hasattr(dev.__class__, "resume"):
try:
dev.resume()
except:
logger.warning("Exception when resuming device %r", dev,
exc_info=True)
def close_devices(self):
"""Closes all active devices, in the opposite order as they were
requested."""
@ -187,11 +163,10 @@ class DeviceManager:
try:
if isinstance(dev, (Client, BestEffortClient)):
dev.close_rpc()
elif hasattr(dev.__class__, "close"):
elif hasattr(dev, "close"):
dev.close()
except:
logger.warning("Exception when closing device %r", dev,
exc_info=True)
except Exception as e:
logger.warning("Exception %r when closing device %r", e, dev)
self.active_devices.clear()