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 clearing the list of actors #4037

Merged
merged 3 commits into from
Dec 14, 2020
Merged

Fix clearing the list of actors #4037

merged 3 commits into from
Dec 14, 2020

Conversation

jngrad
Copy link
Member

@jngrad jngrad commented Dec 11, 2020

Fixes #4033

Description of changes:

  • rewrite the Actors.clear() method so that it removes all actors

The list of actors cannot be cleared completely because the size of
the list changes during iteration, leading to early exit. This bug
is present since release 4.0.0.
@RudolfWeeber RudolfWeeber added the automerge Merge with kodiak label Dec 14, 2020
@@ -231,8 +231,8 @@ class Actors:

def clear(self):
"""Remove all actors."""
for a in self.active_actors:
self.remove(a)
while len(self.active_actors):
Copy link
Member

Choose a reason for hiding this comment

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

why don't we use the clear method of python lists?

@@ -231,8 +231,8 @@ class Actors:

def clear(self):
"""Remove all actors."""
for a in self.active_actors:
self.remove(a)
while len(self.active_actors):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
while len(self.active_actors):
self.active_actors.clear()

@RudolfWeeber
Copy link
Contributor

RudolfWeeber commented Dec 14, 2020 via email

@kodiakhq kodiakhq bot merged commit e2f42d3 into espressomd:python Dec 14, 2020
@jngrad jngrad deleted the fix-4033 branch December 14, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The list of actors cannot be cleared
3 participants