Skip to content

Commit

Permalink
Added try-catch to notification close in symbol destructor (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoRoos authored Jul 30, 2024
1 parent 178a521 commit 39e9c58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* [#293](https://github.com/stlehmann/pyads/pull/2939) Support WSTRINGS in structures

### Changed
* [#304](https://github.com/stlehmann/pyads/pull/304) Implemented try-catch when closing ADS notifications in AdsSymbol destructor
* [#292](https://github.com/stlehmann/pyads/pull/292) Improve performance of get_value_from_ctype_data for arrays
* [#363](https://github.com/stlehmann/pyads/pull/363) Allow for platform independent builds

Expand Down
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 39e9c58

Please sign in to comment.