Open dancingdarwin opened 7 years ago
Does sound like a workaround instead of a good fix for this race condition.
Von meinem Samsung Gerät gesendet.
-------- Ursprüngliche Nachricht -------- Von: dancingdarwin notifications@github.com Datum: 02.01.2017 00:46 (GMT+01:00) An: metachris/RPIO RPIO@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Betreff: [metachris/RPIO] Python 3.4 TCP Client Keys (#90)
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. Best,
Jeff
Traceback (most recent call last): File "rpi_client.py", line 66, in
You can view, comment on, or merge this pull request online at: https://github.com/metachris/RPIO/pull/90
Commit Summary
Fixed issue with Python 3.4 TCP Client Keys
File Changes
M
source/RPIO/_RPIO.py
(2)
Patch Links:
https://github.com/metachris/RPIO/pull/90.patch https://github.com/metachris/RPIO/pull/90.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/metachris/RPIO","title":"metachris/RPIO","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/metachris/RPIO"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Python 3.4 TCP Client Keys (#90)"}],"action":{"name":"View Pull Request","url":"https://github.com/metachris/RPIO/pull/90"}}}
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?
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