Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a retry after pt.InterpolatedValues or pt.RecordedValues timeout #10

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions src/data_agent_osisoft_pi/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
# from OSIsoft.AF.Asset import * # noqa: E402
# from OSIsoft.AF.UnitsOfMeasure import * # noqa: E402
from OSIsoft.AF.Data import AFBoundaryType # noqa: E402
from OSIsoft.AF.PI import PIPoint, PIPointType, PIServers # noqa: E402
from OSIsoft.AF.PI import ( # noqa: E402
PIPoint,
PIPointType,
PIServers,
PITimeoutException,
)
from OSIsoft.AF.Time import AFTime, AFTimeRange, AFTimeSpan # noqa: E402

# from System import TimeSpan # noqa: E402
Expand Down Expand Up @@ -389,9 +394,17 @@ def read_tag_values_period(
page_time_range = AFTimeRange(next_start_time, next_end_time)

# https://docs.aveva.com/bundle/af-sdk/page/html/M_OSIsoft_AF_PI_PIPoint_InterpolatedValues.htm
records = pt.InterpolatedValues(
page_time_range, time_span, "", False
)
try:
records = pt.InterpolatedValues(
page_time_range, time_span, "", False
)
except PITimeoutException as e:
log.warn(
f"Retrying after pt.InterpolatedValues timeout: {e}"
)
records = pt.InterpolatedValues(
page_time_range, time_span, "", False
)

if records.Count == 0:
break
Expand Down Expand Up @@ -436,9 +449,15 @@ def read_tag_values_period(
values_to_read = min(self._page_size, total_values_to_read)

# https://docs.aveva.com/bundle/af-sdk/page/html/M_OSIsoft_AF_PI_PIPoint_RecordedValues.htm
records = pt.RecordedValues(
page_time_range, boundary, "", False, values_to_read
)
try:
records = pt.RecordedValues(
page_time_range, boundary, "", False, values_to_read
)
except PITimeoutException as e:
log.warn(f"Retrying after pt.RecordedValues timeout: {e}")
records = pt.RecordedValues(
page_time_range, boundary, "", False, values_to_read
)

if records.Count == 0:
break
Expand Down