Opened 4 years ago

Closed 4 years ago

#32066 closed Bug (needsinfo)

Sporadic FileNotFoundError on source changes with runserver

Reported by: Anton Yanchenko Owned by: nobody
Component: Core (Other) Version: 3.1
Severity: Normal Keywords:
Cc: Tom Forbes Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm developing locally with docker-compose and mounted sources to Docker container as a volume. Sometimes after saving my changes starting to get FileNotFoundError during request. Here is a traceback:

Environment:


Request Method: POST
Request URL: http://local.dsm.com/e/add/

Django Version: 3.1.1
Python Version: 3.8.5
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'crispy_forms',
 'dsm.core',
 'dsm.users',
 'dsm.events']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "/opt/venv/lib/python3.8/site-packages/asgiref/sync.py", line 330, in thread_handler
    raise exc_info[1]
  File "/opt/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 38, in inner
    response = await get_response(request)
  File "/opt/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 261, in _get_response_async
    response = await sync_to_async(response.render, thread_sensitive=True)()
  File "/opt/venv/lib/python3.8/site-packages/asgiref/sync.py", line 296, in __call__
    ret = await asyncio.wait_for(future, timeout=None)
  File "/usr/local/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
    return await fut
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/opt/venv/lib/python3.8/site-packages/asgiref/sync.py", line 334, in thread_handler
    return func(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/opt/venv/lib/python3.8/site-packages/django/template/response.py", line 81, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/opt/venv/lib/python3.8/site-packages/django/template/response.py", line 63, in resolve_template
    return select_template(template, using=self.using)
  File "/opt/venv/lib/python3.8/site-packages/django/template/loader.py", line 42, in select_template
    return engine.get_template(template_name)
  File "/opt/venv/lib/python3.8/site-packages/django/template/backends/django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "/opt/venv/lib/python3.8/site-packages/django/template/engine.py", line 143, in get_template
    template, origin = self.find_template(template_name)
  File "/opt/venv/lib/python3.8/site-packages/django/template/engine.py", line 125, in find_template
    template = loader.get_template(name, skip=skip)
  File "/opt/venv/lib/python3.8/site-packages/django/template/loaders/base.py", line 18, in get_template
    for origin in self.get_template_sources(template_name):
  File "/opt/venv/lib/python3.8/site-packages/django/template/loaders/filesystem.py", line 36, in get_template_sources
    name = safe_join(template_dir, template_name)
  File "/opt/venv/lib/python3.8/site-packages/django/utils/_os.py", line 17, in safe_join
    final_path = abspath(join(base, *paths))
  File "/usr/local/lib/python3.8/posixpath.py", line 379, in abspath
    cwd = os.getcwd()

Exception Type: FileNotFoundError at /e/add/
Exception Value: [Errno 2] No such file or directory

After error happened it preserves until I modify sources (python files or templates) one more time. I'm not exactly sure, but maybe it happens only if I send request to the server almost immediately after editing file, unfortunately it's hard to say for sure because sometimes it happens very occasionally, sometimes quite often (taking into account that Docker itself could easily occupy a whole core because it's own issues, it could also interfere to this issue).

https://code.djangoproject.com/ticket/30647 - perhaps this is similar somehow.

Change History (1)

comment:1 by Mariusz Felisiak, 4 years ago

Cc: Tom Forbes added
Component: UncategorizedCore (Other)
Resolution: needsinfo
Status: newclosed

Thanks for this ticket, marking as needsinfo because we don't have a way to reproduce this issue. Can you provide a sample project or details about your Docker image? Can you reproduce the same issue in Django 3.0.X?

Note: See TracTickets for help on using tickets.
Back to Top