1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Django autoreload raises: TypeError: unhashable type: 'types.SimpleNamespace'

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    When I upgrade importlib_meta from version 8.4.0 to 8.5.0 (released just yesterday, Sep 11 2024), I get the following error when I start running the development server with python manage.py runserver:

    File "/app/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
    File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
    File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 75, in execute
    super().execute(*args, **options)
    File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
    File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 112, in handle
    self.run(**options)
    File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 119, in run
    autoreload.run_with_reloader(self.inner_run, **options)
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 671, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 660, in start_django
    reloader.run(django_main_thread)
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 344, in run
    self.run_loop()
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 350, in run_loop
    next(ticker)
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 390, in tick
    for filepath, mtime in self.snapshot_files():
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 411, in snapshot_files
    for file in self.watched_files():
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 304, in watched_files
    yield from iter_all_python_module_files()
    File "/usr/local/lib/python3.10/site-packages/django/utils/autoreload.py", line 120, in iter_all_python_module_files
    return iter_modules_and_files(modules, frozenset(_error_files))
    TypeError: unhashable type: 'types.SimpleNamespace'


    I actually could narrow the problem down to the following commit https://github.com/python/importlib_metadata/commit/56b61b3dd90df2dba2da445a8386029b54fdebf3.

    When I install importlib_meta just one commit before the problematic commit via pip install git+https://github.com/python/importlib_metadata@d968f6270d55f27a10491344a22e9e0fd77b5583 the error disappears. When I install importlib_meta at the problematic commit the error starts to appear.

    I can not really make sense out of the Traceback and how the problem might be connected to the changes of the mentioned commit. Has anyone an idea what could cause this problem or how I can debug it?

    Continue reading...

Compartilhe esta Página