Skip to content

Commit

Permalink
Added try-catch to notification close in symbol destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoRoos committed Jan 12, 2022
1 parent fd1c361 commit d5336fb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyads/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from . import constants # To access all constants, use package notation
from .constants import PLCDataType
from .pyads_ex import adsGetSymbolInfo
from .pyads_ex import adsGetSymbolInfo, ADSError
from .structs import NotificationAttrib

# ads.Connection relies on structs.AdsSymbol (but in type hints only), so use
Expand Down Expand Up @@ -229,7 +229,10 @@ def __repr__(self) -> str:

def __del__(self) -> None:
"""Destructor"""
self.clear_device_notifications()
try:
self.clear_device_notifications()
except ADSError:
pass # Quietly continue, without a connection no cleanup could be done

def add_device_notification(
self,
Expand Down

0 comments on commit d5336fb

Please sign in to comment.