Hi,
I confirm nginx is really sending the REQUEST_METHOD header with
nginx/uwsgi:
04:33:37.008721 read(6, "\0\274\1\0\f\0QUERY_STRING\0\0\16\0REQUEST_METHOD\3\0GET\f\0CONTENT_TYPE\0\0\16\0CONTENT_LENGTH\0\0\v\0REQUEST_URI\v\0/benchmark/\t\0PATH_INFO\v\0/benchmark/\r\0DOCUMENT_ROOT!\0/home/erob/www/isotopesoftware.ca\17\0SERVER_PROTOCOL\10\0HTTP/1.1\v\0REMOTE_ADDR\t\000127.0.0.1\v\0REMOTE_PORT\5\00041286\v\0SERVER_PORT\2\00080\v\0SERVER_NAME\t\0localhost\v\0REMOTE_USER\0\0\v\0SCRIPT_NAME\0\0\7\0HTTP_TE\22\0deflate,gzip;q=0.3\17\0HTTP_CONNECTION\t\0TE, close\t\0HTTP_HOST\t\0localhost\17\0HTTP_USER_AGENT!\0lwp-request/6.15 libwww-perl/6.15", 4100) = 448
So I tried to hack pypy_setup.py by using iov.iov_len as a replacement for wsgi_req.var_cnt and here's the result:
environ = {}
 iov = wsgi_req.hvec
for i in range(0, iov.iov_len, 2):
       environ[ffi.string(ffi.cast("char*", iov[i].iov_base),
iov[i].iov_len)] = ffi.string(ffi.cast("char*", iov[i+1].iov_base),
iov[i+1].iov_len)
Now the traceback is somewhat different. Progress! :-)
ENVIRON:
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
ENVIRON: PYTHONHOME=/usr
ENVIRON: XDG_MENU_PREFIX=xfce-
ENVIRON: LANG=en_CA.utf8
ENVIRON: DISPLAY=:0.0
ENVIRON: OLDPWD=/home/erob/src/django-hotsauce-0.9/tests/benchmarks/lib/pypy
ENVIRON: COLORTERM=rxvt
ENVIRON: XDG_VTNR=7
ENVIRON: SSH_AUTH_SOCK=/tmp/ssh-sarMdiJdtI4D/agent.775
ENVIRON: GLADE_CATALOG_PATH=:
ENVIRON: XDG_SESSION_ID=2
ENVIRON: XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/erob
ENVIRON: USER=erob
ENVIRON: GLADE_MODULE_PATH=:
ENVIRON: DESKTOP_SESSION=lightdm-xsession
ENVIRON:
PWD=/home/erob/src/django-hotsauce-0.9/tests/benchmarks/lib/pypy/django_sqlite
ENVIRON: HOME=/home/erob
ENVIRON: SSH_AGENT_PID=1042
ENVIRON: QT_ACCESSIBILITY=1
ENVIRON: XDG_SESSION_TYPE=x11
ENVIRON:
XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
ENVIRON: XDG_SESSION_DESKTOP=lightdm-xsession
ENVIRON: GLADE_PIXMAP_PATH=:
ENVIRON: DESKTOP_STARTUP_ID=xfce4-panel/exo-open/1069-0-marina_TIME100892
ENVIRON: TERM=rxvt
ENVIRON: SHELL=/bin/bash
ENVIRON: XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
ENVIRON: XDG_CURRENT_DESKTOP=XFCE
ENVIRON: QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
ENVIRON: SHLVL=1
ENVIRON: COLORFGBG=0;15
ENVIRON: XDG_SEAT=seat0
ENVIRON: LANGUAGE=en_CA:en
ENVIRON: WINDOWID=44040194
ENVIRON: GDMSESSION=lightdm-xsession
ENVIRON: LOGNAME=erob
ENVIRON:
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-iOI2an0AiX,guid=b2939762a51bb6d7f7fca2a75a7c46b9
ENVIRON: XDG_RUNTIME_DIR=/run/user/1000
ENVIRON: QT_XCB_FORCE_SOFTWARE_OPENGL=1
ENVIRON: XAUTHORITY=/home/erob/.Xauthority
ENVIRON: XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
ENVIRON: XDG_CONFIG_DIRS=/etc/xdg
ENVIRON: PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
ENVIRON:
SESSION_MANAGER=local/marina:@/tmp/.ICE-unix/1052,unix/marina:/tmp/.ICE-unix/1052
ENVIRON: _=/usr/local/pypy/bin/uwsgi
ENVIRON: UWSGI_RELOADS=0
max space for custom process name = 2917
[uwsgi-logger] registered "syslog"
[uwsgi-logger] registered "rsyslog"
[uwsgi-logger] registered "socket"
[uwsgi-logger] registered "redislog"
[uwsgi-logger] registered "mongodblog"
[uwsgi-logger] registered "file"
[uwsgi-logger] registered "fd"
[uwsgi-logger] registered "stdio"
[uwsgi-cheaper-algo] registered "busyness"
executable name: /usr/local/pypy/pypy2-v5.9.0-linux32/bin/uwsgi
tmp = /
[uWSGI] getting INI configuration from uwsgi.ini
optind:3 argc:3
[uwsgi-cheaper-algo] registered "spare"
[uwsgi-cheaper-algo] registered "backlog"
[uwsgi-cheaper-algo] registered "manual"
*** Starting uWSGI 2.0.15 (32bit) on [Fri Feb 9 06:30:17 2018] ***
***
*** You are running a DEBUG version of uWSGI, please disable debug in
your build profile and recompile it ***
***
compiled with version: 6.3.0 20170516 on 09 February 2018 06:25:44
os: Linux-4.9.0-5-686-pae #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04)
nodename: marina
machine: i686
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory:
/home/erob/src/django-hotsauce-0.9/tests/benchmarks/lib/pypy/django_sqlite
writing pidfile to /tmp/uwsgi-master.pid
detected binary path: /usr/local/pypy/pypy2-v5.9.0-linux32/bin/uwsgi
chdir() to
/home/erob/src/django-hotsauce-0.9/tests/benchmarks/lib/pypy/django_sqlite
your processes number limit is 11955
your memory page size is 4096 bytes
detected max file descriptor number: 1024
cores allocated...
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
Initialized PyPy with Python 2.7.13 (84a2f3e6a7f8, Oct 03 2017, 12:58:57)
[PyPy 5.9.0 with GCC 4.6.3]
PyPy Home: /usr/local/pypy/pypy2-v5.9.0-linux32
[uWSGI DEBUG] uwsgi socket 256 SO_RCVBUF size: 87380
[uWSGI DEBUG] uwsgi socket 256 SO_SNDBUF size: 16384
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 127976 bytes (124 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 14858)
spawned uWSGI worker 1 (pid: 14861, cores: 1)
adding 6 to signal poll
[uWSGI DEBUG] PATH_INFO=/benchmark/
[uWSGI DEBUG] SERVER_NAME=localhost
[uWSGI DEBUG] SCRIPT_NAME=
[uWSGI DEBUG] HTTP_HOST=localhost
{'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'CONTENT_TYPE': '',
'CONTENT_LENGTH': '', 'REQUEST_URI':'/benchmark/', 'PATH_INFO':
'/benchmark/'}
Internal Server Error:/benchmark/
Traceback (most recent call last):
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
41, in inner
   response = get_response(request)
 File "/home/erob/ncvs/django/django/utils/deprecation.py", line 138,
in __call__
   response = self.process_request(request)
 File "/home/erob/ncvs/django/django/middleware/common.py", line 57,
in process_request
   host = request.get_host()
 File "/home/erob/ncvs/django/django/http/request.py", line 97, in
get_host
   host = self._get_raw_host()
 File "/home/erob/ncvs/django/django/http/request.py", line 89, in
_get_raw_host
   host = self.META['SERVER_NAME']
KeyError: u'SERVER_NAME'
Internal Server Error:/benchmark/
Traceback (most recent call last):
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
41, in inner
   response = get_response(request)
 File "/home/erob/ncvs/django/django/utils/deprecation.py", line 140,
in __call__
   response = self.get_response(request)
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
43, in inner
   response = response_for_exception(request, exc)
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
93, in response_for_exception
   response = handle_uncaught_exception(request,
get_resolver(get_urlconf()), sys.exc_info())
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
139, in handle_uncaught_exception
   return debug.technical_500_response(request, *exc_info)
 File "/home/erob/ncvs/django/django/views/debug.py", line 84, in
technical_500_response
   html = reporter.get_traceback_html()
 File "/home/erob/ncvs/django/django/views/debug.py", line 328, in
get_traceback_html
   return t.render(c)
 File "/home/erob/ncvs/django/django/template/base.py", line 207, in
render
   return self._render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 199, in
_render
   return self.nodelist.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 990, in
render
   bit = node.render_annotated(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 957, in
render_annotated
   return self.render(context)
 File "/home/erob/ncvs/django/django/template/defaulttags.py", line
322, in render
   return nodelist.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 990, in
render
   bit = node.render_annotated(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 957, in
render_annotated
   return self.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 1040, in
render
   output = self.filter_expression.resolve(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 708, in
resolve
   obj = self.var.resolve(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 849, in
resolve
   value = self._resolve_lookup(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 911, in
_resolve_lookup
   current = current()
 File "/home/erob/ncvs/django/django/http/request.py", line 162, in
get_raw_uri
   host=self._get_raw_host(),
 File "/home/erob/ncvs/django/django/http/request.py", line 89, in
_get_raw_host
   host = self.META['SERVER_NAME']
KeyError: u'SERVER_NAME'
Internal Server Error:/benchmark/
Traceback (most recent call last):
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
41, in inner
   response = get_response(request)
 File "/home/erob/ncvs/django/django/utils/deprecation.py", line 140,
in __call__
   response = self.get_response(request)
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
43, in inner
   response = response_for_exception(request, exc)
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
93, in response_for_exception
   response = handle_uncaught_exception(request,
get_resolver(get_urlconf()), sys.exc_info())
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
139, in handle_uncaught_exception
   return debug.technical_500_response(request, *exc_info)
 File "/home/erob/ncvs/django/django/views/debug.py", line 84, in
technical_500_response
   html = reporter.get_traceback_html()
 File "/home/erob/ncvs/django/django/views/debug.py", line 328, in
get_traceback_html
   return t.render(c)
 File "/home/erob/ncvs/django/django/template/base.py", line 207, in
render
   return self._render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 199, in
_render
   return self.nodelist.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 990, in
render
   bit = node.render_annotated(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 957, in
render_annotated
   return self.render(context)
 File "/home/erob/ncvs/django/django/template/defaulttags.py", line
322, in render
   return nodelist.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 990, in
render
   bit = node.render_annotated(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 957, in
render_annotated
   return self.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 1040, in
render
   output = self.filter_expression.resolve(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 708, in
resolve
   obj = self.var.resolve(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 849, in
resolve
   value = self._resolve_lookup(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 911, in
_resolve_lookup
   current = current()
 File "/home/erob/ncvs/django/django/http/request.py", line 162, in
get_raw_uri
   host=self._get_raw_host(),
 File "/home/erob/ncvs/django/django/http/request.py", line 89, in
_get_raw_host
   host = self.META['SERVER_NAME']
KeyError: u'SERVER_NAME'
From cffi callback <function uwsgi_pypy_wsgi_handler at 0xb379fbd0>:
Traceback (most recent call last):
 File "c callback", line 478, in uwsgi_pypy_wsgi_handler
 File "./benchmark/wsgi.py", line 20, in application
   return WSGIHandler()(environ, start_response)
 File "/home/erob/ncvs/django/django/core/handlers/wsgi.py", line 157,
in __call__
   response = self.get_response(request)
 File "/home/erob/ncvs/django/django/core/handlers/base.py", line 124,
in get_response
   response = self._middleware_chain(request)
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
43, in inner
   response = response_for_exception(request, exc)
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
93, in response_for_exception
   response = handle_uncaught_exception(request,
get_resolver(get_urlconf()), sys.exc_info())
 File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
139, in handle_uncaught_exception
   return debug.technical_500_response(request, *exc_info)
 File "/home/erob/ncvs/django/django/views/debug.py", line 84, in
technical_500_response
   html = reporter.get_traceback_html()
 File "/home/erob/ncvs/django/django/views/debug.py", line 328, in
get_traceback_html
   return t.render(c)
 File "/home/erob/ncvs/django/django/template/base.py", line 207, in
render
   return self._render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 199, in
_render
   return self.nodelist.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 990, in
render
   bit = node.render_annotated(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 957, in
render_annotated
   return self.render(context)
 File "/home/erob/ncvs/django/django/template/defaulttags.py", line
322, in render
   return nodelist.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 990, in
render
   bit = node.render_annotated(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 957, in
render_annotated
   return self.render(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 1040, in
render
   output = self.filter_expression.resolve(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 708, in
resolve
   obj = self.var.resolve(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 849, in
resolve
   value = self._resolve_lookup(context)
 File "/home/erob/ncvs/django/django/template/base.py", line 911, in
_resolve_lookup
   current = current()
 File "/home/erob/ncvs/django/django/http/request.py", line 162, in
get_raw_uri
   host=self._get_raw_host(),
 File "/home/erob/ncvs/django/django/http/request.py", line 89, in
_get_raw_host
   host = self.META['SERVER_NAME']
KeyError: u'SERVER_NAME'
[pid: 14861|app: -1|req: -1/1] 127.0.0.1 () {36 vars in 444 bytes} [Fri
Feb 9 11:30:23 2018] GET/benchmark/ => generated 0 bytes in 1729 msecs
(HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
SIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
goodbye to uWSGI.
VACUUM: pidfile removed.
Post by Krzysztof WarzechaHello,
Post by Etienne RobillardHi Krzysztof,
http://lists.unbit.it/pipermail/uwsgi/2014-June/007389.html
So I followed Roberto's suggestion and removed my __pycache__ dir but the
issue is persisting.
What do you think? Should i attempt to patch pypy_setup.py ?
Yes, this looks like sensible next step.
But just to be sure, before you do that, confirm that your nginx is
correctly sending REQUEST_METHOD header to 127.0.0.1:8000.
--
Etienne Robillard
***@yandex.com
https://www.isotopesoftware.ca/