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

Fix dictionary changed size during iteration #142 #143

Closed
wants to merge 3 commits into from

Conversation

leozc
Copy link

@leozc leozc commented Jul 9, 2016

copy the key to a list before iterating to prevent the error.

It is less performance since keys were copied, and there should be better approaches

@yannmh yannmh added this to the 0.13.0 milestone Jul 11, 2016
@yannmh
Copy link
Member

yannmh commented Jul 11, 2016

Thanks for fixing the issue @leozc 🙇 .

We'll merge your contribution very shortly.

@yannmh yannmh self-assigned this Jul 11, 2016
@@ -139,7 +139,7 @@ def add_point(self, metric, tags, timestamp, value, metric_class, sample_rate=1,
def flush(self, timestamp):
""" Flush all metrics up to the given timestamp. """
interval = timestamp - timestamp % self._roll_up_interval
past_intervals = [i for i in self._metrics if i < interval]
past_intervals = [i for i in list(self._metrics.keys()) if i < interval]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._metrics.keys() already creates a copy of self._metrics keys. Let's remove the extra list(...).

@yannmh
Copy link
Member

yannmh commented Aug 24, 2016

@leozc I made the change and opened a new PR #151. I am closing this one, thanks again for fixing the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants