[Django] #22017: RuntimeError: dictionary changed size during iteration

28 views
Skip to first unread message

Django

unread,
Feb 11, 2014, 3:48:36 PM2/11/14
to django-...@googlegroups.com
#22017: RuntimeError: dictionary changed size during iteration
-------------------------------+-------------------------
Reporter: quinox | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7-alpha-1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------
This bug report is identical to #21049 but for Django 1.7.

I run Django 1.7a2 with a Python3 virtualenv. Occasionally the runserver
crashes with the following stacktrace:

{{{
System check identified no issues (0 silenced).
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/core/management/__init__.py", line 427, in
execute_from_command_line
utility.execute()
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/core/management/base.py", line 287, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/core/management/base.py", line 336, in execute
output = self.handle(*args, **options)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/core/management/commands/runserver.py", line 81, in handle
self.run(*args, **options)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/core/management/commands/runserver.py", line 90, in run
autoreload.main(self.inner_run, args, options)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 267, in main
reloader(wrapped_main_func, args, kwargs)
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 233, in python_reloader
reloader_thread()
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 212, in reloader_thread
if fn():
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 139, in inotify_code_changed
update_watch()
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 132, in update_watch
for path in gen_filenames():
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 84, in gen_filenames
filenames = [filename.__file__ for filename in sys.modules.values()
File "/home/quinox/projecten/deadlines/virtual/lib/python3.3/site-
packages/django/utils/autoreload.py", line 84, in <listcomp>
filenames = [filename.__file__ for filename in sys.modules.values()
RuntimeError: dictionary changed size during iteration
}}}

The issue shows up sporadically, it can usually be triggered within 10
minutes by running the following command in a shell:
{{{
#!bash
while true ; do touch project/xxx/models.py ; sleep 1s; done
}}}


The fix as suggested in #21049 seems to fix the issue, I haven't seen the
runserver crash since I modified `django/utils/autoreload.py` lines 84-85
from:
{{{
#!python
filenames = [filename.__file__ for filename in sys.modules.values()
if hasattr(filename, '__file__')]
}}}
to
{{{
#!python
filenames = [filename.__file__ for filename in list(sys.modules.values())
if hasattr(filename, '__file__')]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22017>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 12, 2014, 1:47:26 AM2/12/14
to django-...@googlegroups.com
#22017: RuntimeError: dictionary changed size during iteration
--------------------------+---------------------------------------
Reporter: quinox | Owner: nobody
Type: Bug | Status: new
Component: Python 3 | Version: 1.7-alpha-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------+---------------------------------------
Changes (by quinox):

* cc: djangoproject.com@… (added)
* needs_better_patch: => 0
* component: Uncategorized => Python 3
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug


--
Ticket URL: <https://code.djangoproject.com/ticket/22017#comment:1>

Django

unread,
Feb 12, 2014, 4:26:06 AM2/12/14
to django-...@googlegroups.com
#22017: RuntimeError: dictionary changed size during iteration
--------------------------+---------------------------------------
Reporter: quinox | Owner: nobody

Type: Bug | Status: new
Component: Python 3 | Version: 1.7-alpha-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------+---------------------------------------
Changes (by claudep):

* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Regression was introduced in 15f82c701161b327cef54b469c00b6cbe01534db.

--
Ticket URL: <https://code.djangoproject.com/ticket/22017#comment:2>

Django

unread,
Feb 12, 2014, 4:26:36 AM2/12/14
to django-...@googlegroups.com
#22017: RuntimeError: dictionary changed size during iteration
--------------------------+---------------------------------------
Reporter: quinox | Owner: nobody
Type: Bug | Status: closed

Component: Python 3 | Version: 1.7-alpha-1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------+---------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"e0381cdf2e7f677c5b29f2e3351993e92915569a"]:
{{{
#!CommitTicketReference repository=""
revision="e0381cdf2e7f677c5b29f2e3351993e92915569a"
Fixed #22017 -- Prevented RuntimeError on Python 3

Refs #21049. Thanks quinox for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22017#comment:3>

Django

unread,
Apr 2, 2014, 12:47:38 PM4/2/14
to django-...@googlegroups.com
#22017: RuntimeError: dictionary changed size during iteration
--------------------------+---------------------------------------
Reporter: quinox | Owner: nobody

Type: Bug | Status: closed
Component: Python 3 | Version: 1.7-alpha-1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------+---------------------------------------

Comment (by Alex Gaynor <alex.gaynor@…>):

In [changeset:"608e6eb2959c6e56e5c702ca0d15fa0e6c2eef16"]:
{{{
#!CommitTicketReference repository=""
revision="608e6eb2959c6e56e5c702ca0d15fa0e6c2eef16"
Added an explanatory comment. Refs #22017
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22017#comment:4>

Reply all
Reply to author
Forward
0 new messages