When running runserver command, we are getting the error below which makes breaks the runserver command:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/checks.py", line 55, in check_admin_app
for site in all_sites:
File "/usr/local/lib/python3.7/_weakrefset.py", line 60, in __iter__
for itemref in self.data:
RuntimeError: Set changed size during iteration
This issue started to happen out of nowhere, since all the code related to AdminSite's wasn't modified in months. It's also not happening every time, but increasing in frequency of occurrence.
It doesn't seem to be related to the current implementation, since it's a django's runserver issue during the system checks, but here are the Implementation details:
class PaymentsAdminSite(AdminSite):
site_header = "Payments Admin Site"
site = PaymentsAdminSite(name="payments-admin")
@admin.register(models.Payment, site=site)
class PaymentsAdmin(admin.ModelAdmin):
def cancel(self, request, queryset):
pass
actions = (cancel,)
def get_queryset(self, request):
return models.Payment.objects.all()
# urls.py
url(r"^payments-admin/", site.urls)