Skip to content

Reloader crashes on Python 3 occasionally... #1244

Closed
wants to merge 1 commit into from

2 participants

@ztane
ztane commented Feb 15, 2014

... because dict.values() return a view that throws RuntimeError: dictionary changed size during iteration if the backed collection is changed during iteration.

@ztane ztane Reloader crashes on Python 3 occasionally...
... because dict.values() return a view that throws `RuntimeError: dictionary changed size during iteration` if the backed collection is changed during iteration.
8be9dce
@tseaver tseaver commented on the diff Feb 15, 2014
pyramid/scripts/pserve.py
@@ -811,7 +811,12 @@ def check_reload(self):
print(
"Error calling reloader callback %r:" % file_callback)
traceback.print_exc()
- for module in sys.modules.values():
+
+ modules = sys.modules.values()
+ if PY3:
+ modules = list(modules)
+
+ for module in modules:
@tseaver
Pylons Project member
tseaver added a note Feb 15, 2014

It would be safer / simpler just to convert to a list unconditionally, e.g.::

for module in list(sys.modules.values()):
    ...
@ztane
ztane added a note Feb 16, 2014

True, so now there is a choice: #1245.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ztane ztane added a commit to ztane/pyramid that referenced this pull request Feb 16, 2014
@ztane ztane Fix pserve --reload on Py3 (the simple solution)
This is the simpler fix for `pserve --reload` (so please pull either Pylons#1244 or this).

Basically with some project setups the reloader thread is guaranteed to crash on Python 3 as the main thread is importing modules in the other thread.
606a54c
@tseaver
Pylons Project member
tseaver commented Feb 16, 2014

Closed in favor of #1245. Next time, you could just push another commit to the branch for the original PR, rather than opening a new one.

@tseaver tseaver closed this Feb 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.