Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Python 3.4 TCP Client Keys #90

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open

Conversation

dancingdarwin
Copy link

@dancingdarwin dancingdarwin commented Jan 1, 2017

Hi there,
When you run RPIO.cleanup_tcpsockets() on a RPi Model B+ running Python 3.4 then you get an error message about your dictionary changing sizes during iterations (see error message below). I think the issue was because keys() now returns an iterable instead of a list in Python 3, so I just wrapped list around it to get a static list that wouldn't change size. I tested it and it doesn't interfere with the DMA PWM stuff at least, and I don't get thrown the error anymore. This would decrease performance only a tiny bit anyways as a type safety issue.

Thanks so much for an awesome package and happy new year!

Best,
Jeff

Traceback (most recent call last): File "rpi_client.py", line 66, in <module> RPIO.wait_for_interrupts() content.strip()) File "rpi_client.py", line 24, in tcp_callback RPIO.cleanup() File "/usr/local/lib/python3.4/dist-packages/RPIO-2.0.0_beta1-py3.4-linux-armv6l.egg/RPIO/__init__.py", line 281, in cleanup cleanup_interrupts() File "/usr/local/lib/python3.4/dist-packages/RPIO-2.0.0_beta1-py3.4-linux-armv6l.egg/RPIO/__init__.py", line 271, in cleanup_interrupts _rpio.cleanup_interrupts() File "/usr/local/lib/python3.4/dist-packages/RPIO-2.0.0_beta1-py3.4-linux-armv6l.egg/RPIO/_RPIO.py", line 368, in cleanup_interrupts self.cleanup_tcpsockets() File "/usr/local/lib/python3.4/dist-packages/RPIO-2.0.0_beta1-py3.4-linux-armv6l.egg/RPIO/_RPIO.py", line 353, in cleanup_tcpsockets for fileno in self._tcp_client_sockets.keys(): RuntimeError: dictionary changed size during iteration

@DEvil0000
Copy link

DEvil0000 commented Jan 2, 2017 via email

@dancingdarwin
Copy link
Author

Hmm. Another way to resolve this is by using one for loop to close the connections and then deleting the keys from the dictionary with dict.clear(). How does that sound to you?

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

Successfully merging this pull request may close these issues.

2 participants