Skip to content

Commit

Permalink
MNT: Avoid issues when somehow we try to disconnect from an already d…
Browse files Browse the repository at this point in the history
…isconnected channel.
  • Loading branch information
Hugo Slepicka committed Jun 5, 2018
1 parent c401a10 commit a1fe1ec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
8 changes: 4 additions & 4 deletions pydm/data_plugins/epics_plugins/pyepics_plugin_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ def remove_listener(self, channel):
if channel.value_signal is not None:
try:
channel.value_signal[str].disconnect(self.put_value)
except KeyError:
except (KeyError, TypeError):
pass
try:
channel.value_signal[int].disconnect(self.put_value)
except KeyError:
except (KeyError, TypeError):
pass
try:
channel.value_signal[float].disconnect(self.put_value)
except KeyError:
except (KeyError, TypeError):
pass
try:
channel.value_signal[np.ndarray].disconnect(self.put_value)
except KeyError:
except (KeyError, TypeError):
pass

super(Connection, self).remove_listener(channel)
Expand Down
35 changes: 28 additions & 7 deletions pydm/data_plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,46 @@ def remove_listener(self, channel):
pass

if channel.severity_slot is not None:
self.new_severity_signal.disconnect(channel.severity_slot)
try:
self.new_severity_signal.disconnect(channel.severity_slot)
except (KeyError, TypeError):
pass

if channel.write_access_slot is not None:
self.write_access_signal.disconnect(channel.write_access_slot)
try:
self.write_access_signal.disconnect(channel.write_access_slot)
except (KeyError, TypeError):
pass

if channel.enum_strings_slot is not None:
self.enum_strings_signal.disconnect(channel.enum_strings_slot)
try:
self.enum_strings_signal.disconnect(channel.enum_strings_slot)
except (KeyError, TypeError):
pass

if channel.unit_slot is not None:
self.unit_signal.disconnect(channel.unit_slot)
try:
self.unit_signal.disconnect(channel.unit_slot)
except (KeyError, TypeError):
pass

if channel.upper_ctrl_limit_slot is not None:
self.upper_ctrl_limit_signal.disconnect(channel.upper_ctrl_limit_slot)
try:
self.upper_ctrl_limit_signal.disconnect(channel.upper_ctrl_limit_slot)
except (KeyError, TypeError):
pass

if channel.lower_ctrl_limit_slot is not None:
self.lower_ctrl_limit_signal.disconnect(channel.lower_ctrl_limit_slot)
try:
self.lower_ctrl_limit_signal.disconnect(channel.lower_ctrl_limit_slot)
except (KeyError, TypeError):
pass

if channel.prec_slot is not None:
self.prec_signal.disconnect(channel.prec_slot)
try:
self.prec_signal.disconnect(channel.prec_slot)
except (KeyError, TypeError):
pass

self.listener_count = self.listener_count - 1
if self.listener_count < 1:
Expand Down

0 comments on commit a1fe1ec

Please sign in to comment.