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 in Photon 1.0.7 #51
Comments
I must add that this is not persistent, reproducing it requires stopping the process via SIGINT, but on my second try it worked without problems and saved the results. Might be related to lag if the session is via SSH where the Photon.py process is ran on the other end. |
Hi there, You did the right by reporting the error your encountered but I am unable to reproduce it.
Would it be appropriate if I mark this issue as |
It wouldn’t, upon four tries the issue was 2/4 positive which makes it false positive negative. |
I am not really sure what is causing the problem, have you tried reproducing it on your local machine? The code block which throws the error is this one: for url in external:
if 'github.com' in url or 'facebook.com' in url or 'instagram.com' in url or 'youtube.com' in url:
intel.add(url) The error suggests that the set we are iterating over gets changed during iteration but as you can see there's no way that can happen. |
You can “freeze” it by changing it to for url in tuple(external):. |
Yep @cclauss , but do you have any idea why its happening? |
My guess as to why this is happening is that one of more threads is adding (or deleting) to external while another thread is trying to iterate through it. https://docs.python.org/3/library/threading.html contains info on Locks and Semaphores, etc. that can be used to guard against these multithread contention issues. |
Can be the case, used 50 threads at the time. |
In such a multi-threaded environment, https://docs.python.org/3/library/queue.html will be much safer than a list. |
I don't think so, I always use 100 threads and never faced any error. |
The text was updated successfully, but these errors were encountered: