Changes between Version 1 and Version 2 of Ticket #35757, comment 12


Ignore:
Timestamp:
Sep 30, 2024, 11:56:26 AM (7 weeks ago)
Author:
Harm Verhagen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35757, comment 12

    v1 v2  
    11I reproduced this problem with a small Django project.
    2 It seems to be related with channels (v3)
     2It seems to be related with channels/daphne
    33
    4 Please advise, if Django related (if so, could you reopen the ticket?)
     4As there is a testcase, I re-opened the ticket for re-evaluation.
     5Please advise if more information is required.
    56
    6 I created a new project according the to polls example. The problem occurs when adding 'channels' to `INSTALLED_APPS`  (without even using channels).
     7I created a new project according the to polls example. The problem occurs when adding 'channels'/'daphne' to `INSTALLED_APPS`  (without even using channels).
    78
    89polls.views.py
     
    3839}
    3940
     41INSTALLED_APPS = [
     42     'daphne',     # must be before staticfiles   (removing this fixes the problem (with channels 4)
     43    'channels',   
    4044
    41 
    42 INSTALLED_APPS = [
    4345    'django.contrib.admin',
    4446    'django.contrib.auth',
     
    4749    'django.contrib.messages',
    4850    'django.contrib.staticfiles',
    49 
    50     'channels',            # adding this line shows the problem, removing this line 'fixes' the problem
    5151]
    5252
    53 
    5453ASGI_APPLICATION = "mysite.asgi.application"                # required for channels
    55 
    56 
    5754}}}
    5855
     
    6259#
    6360# do requests in parallel
    64 #https://code.djangoproject.com/ticket/35757
     61# https://code.djangoproject.com/ticket/35757
    6562url='http://localhost:8000/polls/'
    66 
    6763
    6864curl $url&
     
    7066curl $url&
    7167curl $url
     68}}}
    7269
     70== Result
     71Exceptions as shown in original report.  (`OSError: [Errno 9] Bad file descriptor`)
     72After a few runs runserver stops serving requests completely, all requests, even sequential ones from a browser, get a 500 with this traceback.
     73
     74{{{
     75Traceback (most recent call last):
     76  File "venv/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
     77    raise exc_info[1]
     78  File "venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
     79    response = await get_response(request)
     80  File "venv/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
     81    raise exc_info[1]
     82  File "/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
     83    response = await wrapped_callback(
     84  File "venv/lib/python3.12/site-packages/asgiref/sync.py", line 468, in __call__
     85    ret = await asyncio.shield(exec_coro)
     86  File ".../Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
     87    result = self.fn(*self.args, **self.kwargs)
     88  File "/venv/lib/python3.12/site-packages/asgiref/sync.py", line 522, in thread_handler
     89    return func(*args, **kwargs)
     90  File "mysite/polls/views.py", line 20, in index
     91    incr()
     92  File "mysite/polls/views.py", line 11, in incr
     93    val = cache.incr(key, 1)
     94  File "venv/lib/python3.12/site-packages/django/core/cache/backends/memcached.py", line 110, in incr
     95    val = self._cache.incr(key, delta)
     96  File "venv/lib/python3.12/site-packages/pymemcache/client/hash.py", line 350, in incr
     97    return self._run_cmd("incr", key, False, *args, **kwargs)
     98  File "venv/lib/python3.12/site-packages/pymemcache/client/hash.py", line 314, in _run_cmd
     99    client = self._get_client(key)
     100  File "venv/lib/python3.12/site-packages/pymemcache/client/hash.py", line 182, in _get_client
     101    raise MemcacheError("All servers seem to be down right now")
     102
     103pymemcache.exceptions.MemcacheError: All servers seem to be down right now
    73104}}}
     105
     106
     107
     108
     109== Version info
     110with channels 3 the problem appears (and disappears when removed) when adding 'channels' to INSTALLED_APPS
     111with channels 4 the problem appears when adding 'channels' & 'daphne' to INSTALLED_APPS, disappears when 'daphne' is commented out.
Back to Top