You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure of the exact role that asgiref plays in the Django stack, and specifically how that might vary between a "debug" setup where Django itself - IIUC - serves the incoming requests, versus a "deployment" setup where, in my case, Django is fronted by nginx and gunicorn/uvicorn, so please forgive any inaccuracies in the following description.
I have a Django view whose Jinja template ends up expanding a link to a static URL, like this:
const html = `{{ static(some-directory) }}/a-subdirectory/foo.html`;
In my "debug" setup, this works as expected, but it seems in my "deployment" setup the static(some-directory) ends up throwing the following exception:
ValueError("Missing staticfiles manifest entry for 'some-directory'")
That in itself might be a minor issue, but unfortunately, when that bubbles up to the exception handling starting at
we end up spinning on some Linux futex (according to strace) consuming 100% of the CPU until forcibly SIGKILLd. The stack at this point looks like this:
Traceback (most recent call last):,
File "/home/ubuntu/venv/lib/python3.10/site-packages/asgiref/sync.py", line 534, in thread_handler,
raise exc_info[1],
File "/home/ubuntu/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 42, in inner,
response = await get_response(request),
File "/home/ubuntu/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 253, in _get_response_async,
response = await wrapped_callback(,
File "/home/ubuntu/venv/lib/python3.10/site-packages/asgiref/sync.py", line 479, in __call__,
ret: _R = await loop.run_in_executor(,
File "/home/ubuntu/venv/lib/python3.10/site-packages/asgiref/current_thread_executor.py", line 40, in run,
result = self.fn(*self.args, **self.kwargs),
File "/home/ubuntu/venv/lib/python3.10/site-packages/asgiref/sync.py", line 538, in thread_handler,
return func(*args, **kwargs),
File "/home/ubuntu/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view,
return self.dispatch(request, *args, **kwargs),
File "... our code ...", line 255, in dispatch,
raise RuntimeError("about to return: generic_views.py[255]"),
RuntimeError: about to return: generic_views.py[255],
I'm inclined to described this as a serious failure because:
short of inserting a print("exception=", exc) there was no way to see what the problem was.
the 100% CPU spin is indefinite in duration.
I'm filing this against asgiref without really knowing if the actual error is in one of the other related parties at this point. I am of course, happy to help diagnose the problem further as needed.
I just realised that this only seems to happen for exceptions thrown during template rendering. AFAIK from using the IDE debugger, template rendering does not happen on the same thread that "normal" Django view code code uses. I therefore suspect that there is some unexpected interaction between the thread-sensitive code in asgiref around this point, and the thread that does template rendering.
I'm not sure of the exact role that asgiref plays in the Django stack, and specifically how that might vary between a "debug" setup where Django itself - IIUC - serves the incoming requests, versus a "deployment" setup where, in my case, Django is fronted by nginx and gunicorn/uvicorn, so please forgive any inaccuracies in the following description.
I have a Django view whose Jinja template ends up expanding a link to a
static
URL, like this:In my "debug" setup, this works as expected, but it seems in my "deployment" setup the
static(some-directory)
ends up throwing the following exception:That in itself might be a minor issue, but unfortunately, when that bubbles up to the exception handling starting at
asgiref/asgiref/current_thread_executor.py
Line 42 in 8cf847a
I'm inclined to described this as a serious failure because:
print("exception=", exc)
there was no way to see what the problem was.I'm filing this against asgiref without really knowing if the actual error is in one of the other related parties at this point. I am of course, happy to help diagnose the problem further as needed.
Encls: pip freeze output
The text was updated successfully, but these errors were encountered: