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

RuntimeError: Set changed size during iteration #156

Open
MatthewScholefield opened this issue Aug 15, 2018 · 5 comments
Open

RuntimeError: Set changed size during iteration #156

MatthewScholefield opened this issue Aug 15, 2018 · 5 comments

Comments

@MatthewScholefield
Copy link

MatthewScholefield commented Aug 15, 2018

When constantly reading and writing to the connection, within a few seconds I always get this:

Traceback (most recent call last):
  File "/home/matthew/Documents/GitHub/vokiso/.venv/lib/python3.6/site-packages/py2p/base.py", line 314, in process_data
    handler.found_terminator()
  File "/home/matthew/Documents/GitHub/vokiso/.venv/lib/python3.6/site-packages/py2p/mesh.py", line 63, in found_terminator
    elif self.handle_waterfall(msg, packets):
  File "/home/matthew/Documents/GitHub/vokiso/.venv/lib/python3.6/site-packages/py2p/mesh.py", line 103, in handle_waterfall
    elif not self.server.waterfall(Message(msg, self.server)):
  File "/home/matthew/Documents/GitHub/vokiso/.venv/lib/python3.6/site-packages/py2p/mesh.py", line 530, in waterfall
    self.__clean_waterfalls()
  File "/home/matthew/Documents/GitHub/vokiso/.venv/lib/python3.6/site-packages/py2p/mesh.py", line 512, in __clean_waterfalls
    self.waterfalls = {i for i in self.waterfalls if i[1] > getUTC() - 60}
  File "/home/matthew/Documents/GitHub/vokiso/.venv/lib/python3.6/site-packages/py2p/mesh.py", line 512, in <setcomp>
    self.waterfalls = {i for i in self.waterfalls if i[1] > getUTC() - 60}
RuntimeError: Set changed size during iteration

I'm assuming it's a race condition of some sort.

Edit: This is actually an issue with py2p. Just realized I posted it here.

@LivInTheLookingGlass
Copy link
Collaborator

Hmmm. Looks like you are probably right. I dont think that I can investigate in depth until the weekend, but I will see if I can make a quick patch for that. Probably it is as simple as making a lock for waterfalls.

Might as well add a performance improvement as well. No need to check the time for every single loop through the set.

@MatthewScholefield
Copy link
Author

Yeah, I added a lock and it fixed it.

@LivInTheLookingGlass
Copy link
Collaborator

If you don't mind, could you submit a PR of that?

@LivInTheLookingGlass
Copy link
Collaborator

Hi, I was wondering if you could submit a pull request for that lock, since you have already done it.

@MatthewScholefield
Copy link
Author

Yeah, I'll submit a PR. Just haven't had time recently. Should get time later today.

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

No branches or pull requests

2 participants