[Django] #31372: autoreload: dictionary changed size during iteration

38 views
Skip to first unread message

Django

unread,
Mar 17, 2020, 9:57:16 AM3/17/20
to django-...@googlegroups.com
#31372: autoreload: dictionary changed size during iteration
-------------------------------------+-------------------------------------
Reporter: minusf | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: 2.2
(Management commands) |
Severity: Normal | Keywords: autoreload
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Found this issue recently, not 100% reproducable. Not a huge project,
actually a quite small one. macOS catalina, 10.15.3, python from brew
(/usr/local/bin/python3) 3.7.7, Django 2.2.11, could not reproduce with
3.0.4 in light testing, but maybe it's useful to have this stacktrace
here. (can't move to 3 now because of dependencies btw).

{{{
2020-03-17 14:48:33,118 INFO: autoreload.py:597: Watching for file changes
with WatchmanReloader
Performing system checks...

Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/__init__.py", line 381, in
execute_from_command_line
utility.execute()
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/commands/runserver.py", line 60, in
execute
super().execute(*args, **options)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 301, in run
self.run_loop()
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 307, in run_loop
next(ticker)
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 520, in tick
self.update_watches()
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 493, in update_watches
self._update_watches()
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 476, in _update_watches
watched_files = list(self.watched_files(include_globs=False))
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 262, in watched_files
yield from iter_all_python_module_files()
File "/Users/user/src/venv/lib/python3.7/site-
packages/django/utils/autoreload.py", line 101, in
iter_all_python_module_files
modules_view = sorted(list(sys.modules.items()), key=lambda i: i[0])
RuntimeError: dictionary changed size during iteration
}}}

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

Django

unread,
Mar 17, 2020, 10:02:05 AM3/17/20
to django-...@googlegroups.com
#31372: autoreload: dictionary changed size during iteration
-------------------------------------+-------------------------------------
Reporter: minusf | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 2.2
commands) |
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by minusf):

forgot to add these:
{{{
pywatchman 1.4.1

$ brew info watchman
watchman: stable 4.9.0 (bottled), HEAD
}}}

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

Django

unread,
Mar 17, 2020, 12:24:21 PM3/17/20
to django-...@googlegroups.com
#31372: autoreload: dictionary changed size during iteration
-------------------------------------+-------------------------------------
Reporter: minusf | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 2.2
commands) |
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

Pretty sure this was inadvertently fixed in 3.0 by
1835563ab8a1da949a35316d16989236ac585c6c since `sys.module.items` isn't
used anymore and we only perform `__getitem__` on a fixed collection of
modules.

Since 2.2 is currently only in maintenance mode I don't think this commit
will be backported there.

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

Django

unread,
Mar 17, 2020, 12:55:08 PM3/17/20
to django-...@googlegroups.com
#31372: autoreload: dictionary changed size during iteration
-------------------------------------+-------------------------------------
Reporter: minusf | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 2.2
commands) |
Severity: Normal | Resolution:
Keywords: autoreload | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by minusf):

would you be so kind and explained the core issue? what was touching
sys.modules while beeing looped over it?

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

Django

unread,
Mar 17, 2020, 3:07:02 PM3/17/20
to django-...@googlegroups.com
#31372: Autoreload: dictionary changed size during iteration.
------------------------------+--------------------------------------
Reporter: minusf | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution: wontfix

Keywords: autoreload | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => wontfix
* component: Core (Management commands) => Core (Other)


Comment:

It's hard to say why dictionary changed size during iteration, but I agree
with Simon that it's not an issue in Django 3.0. Unfortunately Django 2.2
is in extended support so it's not receiving such bugfixes/cleanups
anymore.

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

Django

unread,
Mar 22, 2021, 3:49:48 PM3/22/21
to django-...@googlegroups.com
#31372: Autoreload: dictionary changed size during iteration.
------------------------------+--------------------------------------
Reporter: minusf | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution: wontfix
Keywords: autoreload | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"ac72a216a7ef95e8e9cb8651b7e67320597c903b" ac72a216]:
{{{
#!CommitTicketReference repository=""
revision="ac72a216a7ef95e8e9cb8651b7e67320597c903b"
Refs #31372 -- Added django.utils.inspect tests for bound methods.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31372#comment:5>

Django

unread,
Mar 22, 2021, 3:50:46 PM3/22/21
to django-...@googlegroups.com
#31372: Autoreload: dictionary changed size during iteration.
------------------------------+--------------------------------------
Reporter: minusf | Owner: nobody

Type: Bug | Status: closed
Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution: wontfix
Keywords: autoreload | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"2420fd2d5c90698454678c81f3f5a7662be2bf72" 2420fd2]:
{{{
#!CommitTicketReference repository=""
revision="2420fd2d5c90698454678c81f3f5a7662be2bf72"
[3.2.x] Refs #31372 -- Added django.utils.inspect tests for bound methods.

Backport of ac72a216a7ef95e8e9cb8651b7e67320597c903b from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31372#comment:6>

Reply all
Reply to author
Forward
0 new messages