This repository was archived by the owner on Nov 28, 2022. It is now read-only.
Open
Conversation
|
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 <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
You can view, comment on, or merge this pull request online at:
#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":"#90"}}}
|
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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