question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeWarning: Sequential read of iterator was interrupted. Resetting iterator. This can negatively impact the performance.

See original GitHub issue

The RuntimeWarning does not appear in 1.8.17. I think this is a regression introduced in 1.8.18. Related SO question: https://stackoverflow.com/q/64995369/9778755

_Originally posted by @StefanBrand in https://github.com/Toblerity/Fiona/issues/965#issuecomment-737073718_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rbuffatcommented, Dec 2, 2020

So what’s going on is that the list() method seems to call len() before it starts iterating over the Iterator. I assume this is to create an efficient data structure for the list. Would be interesting to look at the implementation of list(). We probably should not emit a warning when the iterator was interrupted before an iteration has actually started.

class Iterator:

    def __init__(self):
        print("__init__")
        self.counter = 0
        self.len = 5

    def __iter__(self):
        print("__iter__")
        return self

    def __next__(self):
        self.counter += 1
        if self.counter > self.len:
            raise StopIteration
        print("__next__", self.counter)
        return self.counter

    def __len__(self):
        print("__len__")
        return self.len

it = Iterator()
print(list(it))

Output:

__init__
__len__
__iter__
__len__
__next__ 1
__next__ 2
__next__ 3
__next__ 4
__next__ 5
0reactions
Robinlovelacecommented, Apr 1, 2022

Thanks for the explanation @rbuffat, sounds reasonable. Checking here it seems that there are indeed later versions available: https://anaconda.org/conda-forge/fiona

I’m guess it may be because we pin the Python version as follows:

name: geocompy
channels:
  - conda-forge
  - default
dependencies:
  - python=3.9

Plan to set that as

  - python>=3.9

Source: https://github.com/geocompr/py/blob/main/environment.yml

Read more comments on GitHub >

github_iconTop Results From Across the Web

Geopandas warning on read_file() - python - Stack Overflow
For the drivers that do not support random access, the resetting of the iterator involves reading all features again up to the iterator...
Read more >
Do-It-Yourself — A course on Geographic Data Science
... RuntimeWarning: Sequential read of iterator was interrupted. Resetting iterator. This can negatively impact the performance. for feature in features_lst ...
Read more >
Extract one geometry type from GML file in GeoPandas
... RuntimeWarning: Sequential read of iterator was interrupted. Resetting iterator. This can negatively impact the performance. for feature ...
Read more >
Netherlands electricity regional time series | Kaggle
Time # Log Message 11.3s 2 from pyarrow import HadoopFileSystem 106.7s 4 for feature in features_lst: 354.3s 6 FutureWarning,
Read more >
Interpolation of signatures to OA and LSOA
... RuntimeWarning: Sequential read of iterator was interrupted. Resetting iterator. This can negatively impact the performance. for feature in features_lst ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found