python 3.x - X-Accel-Redirect doesn't work with python3 and Django 1.5 with non ascii filenames -
i wanted try django python 3.
i use:
- nginx
- uwsgi + python 3 plugin ubuntu repos
- python 3.2
- virtualenv
when made python 2.7 had , worked:
... fname_ascii = fname.encode('utf-8') response = httpresponse() response['x-accel-redirect'] = _convert_file_to_url(fname_ascii) now python 3 replaced 1 line to:
response['x-accel-redirect'] = bytes(_convert_file_to_url(fname), 'utf-8') and caused:
sat apr 6 11:27:30 2013 - !!! uwsgi process 6296 got segmentation fault !!! sat apr 6 11:27:30 2013 - *** backtrace of 6296 *** sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(uwsgi_backtrace+0x25) [0x430a55] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(uwsgi_segfault+0x21) [0x430b31] sat apr 6 11:27:30 2013 - /lib/x86_64-linux-gnu/libc.so.6(+0x364a0) [0x7f2177f544a0] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pybytes_asstring+0) [0x7f217417e280] sat apr 6 11:27:30 2013 - /usr/lib/uwsgi/plugins/python32_plugin.so(py_uwsgi_spit+0x45f) [0x7f217455c5ef] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pyeval_evalframeex+0x6230) [0x7f217405f310] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pyeval_evalcodeex+0x687) [0x7f21741289e7] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(+0x12acff) [0x7f2174128cff] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pyobject_call+0x7a) [0x7f217413f8aa] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(+0xac98d) [0x7f21740aa98d] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pyobject_call+0x7a) [0x7f217413f8aa] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(+0xc773c) [0x7f21740c573c] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pyobject_call+0x7a) [0x7f217413f8aa] sat apr 6 11:27:30 2013 - /usr/lib/libpython3.2mu.so.1.0(pyeval_callobjectwithkeywords+0x47) [0x7f2174180cb7] sat apr 6 11:27:30 2013 - /usr/lib/uwsgi/plugins/python32_plugin.so(python_call+0x24) [0x7f21745592f4] sat apr 6 11:27:30 2013 - /usr/lib/uwsgi/plugins/python32_plugin.so(uwsgi_request_wsgi+0x119) [0x7f217455b6c9] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(wsgi_req_recv+0x7f) [0x40dd5f] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(simple_loop+0x112) [0x42be12] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(uwsgi_ignition+0x18a) [0x430faa] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(uwsgi_start+0x2c36) [0x434586] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi(main+0xed4) [0x40d6e4] sat apr 6 11:27:30 2013 - /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f2177f3f76d] sat apr 6 11:27:30 2013 - /usr/bin/uwsgi() [0x40d781] sat apr 6 11:27:30 2013 - *** end of backtrace *** sat apr 6 11:27:30 2013 - damn ! worker 2 (pid: 6296) died :( trying respawn ... sat apr 6 11:27:30 2013 - respawned uwsgi worker 2 (new pid: 6299) i tried just:
response['x-accel-redirect'] = _convert_file_to_url(fname) but got:
badheadererror @ /my_url header values can't contain newlines (got '=?utf-8?b?...=?=\n =?utf-8....=?=\n =?utf-8?b?...=?=') uwsgi settings changed:
[uwsgi] ... plugins = python32 virtualenv = /pyenvs/p3_general/ if had problem - write know.
or maybe bug. seems uwsgi-plugin's bug.
update 1:
i installed uwsgi 1.9.5 using pip:
starting uwsgi 1.9.5 (64bit) on [sat apr 6 16:27:03 2013] ... python version: 3.2.3 (default, oct 19 2012, 19:55:38) [gcc 4.7.2] the same problem.
and forgot mention - happens filenames have non-ascii symbols (russian in case)
update 2:
using urllib.parse.quote uwsgi works nginx gives errors:
failed (36: file name long)(fixed easily)open() "/data/sort/%d1%84%d1%8b%d0%b2%d0%b0%20%d1%84%d1%8b.ogg" failed (2: no such file or directory)
so problem think - uwsgi + python 3
i suggest use uwsgi stable version (1.4 or 1.9 tree). debian supplied version old , various known bugs
Comments
Post a Comment