Skip to content

Stray StopIteration from DatapointsSubscriptionAPI.iterate_data #2013

@henrikhestnes

Description

@henrikhestnes

System information (please complete the following information):

  • OS: Debian GNU/Linux 12 (bookworm)
  • Python Version: 3.12.7
  • SDK Version: 7.64.7

Error occurred around 2024-11-07 19:07:02 UTC

Describe the bug
In the SDK, specifically within the DatapointsSubscriptionAPI.iterate_data method, there appears to be an unhandled StopIteration exception. This exception is likely triggered by an unprotected next(iterator) call, where the iterator is exhausted without providing a default value or proper handling of the StopIteration exception. As a result, Python raises a RuntimeError when the exception propagates to the generator function. Unfortunately, I do not have the complete stack trace at this time, but I have implemented logging to capture it if the issue reoccurs.

To Reproduce
Run this for long enough

from cognite.client import CogniteClient

client = CogniteClient()

for batch in client.time_series.subscriptions.iterate_data("my_subscription"):
    # Do work. Will at some point get excepted by a `RuntimeError: generator raised StopIteration`

Expected behavior
StopIteration to be caught and properly handled by the SDK instead of propagating to the user.

Additional context
Dataset ID and Subscription External ID can be provided upon request

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions