[uWSGI] Queer nginx-uwsgi-pypy behaviour

Roberto De Ioris roberto at unbit.it
Fri Jun 20 14:10:02 CEST 2014


> Hi list,
>     I've got two issues (not sure if related) with my setup.
>
> First issue:
>     For some odd reason, Pyramid wasn't working because uWSGI wasn't
> handing the nginx variables down to pypy (yes I included the uwsgi_param
> file in nginx's configuration). This led to KeyError(s) because
> "REQUEST_METHOD" and other variables weren't present in uwsgi.environ[].
>
>     A little digging led me to an odd behaviour in the embedded
> pypy_setup.py file concerning lines somewhere 450 lines down:
>
>     for i in range(0, wsgi_req.var_cnt, 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)
>
>     For some reason wsgi_req.var_cnt is 0 even though everything else in
> the iovs are properly populated. This is queer as from the C source,
> var_cnt is incremented while filling up the iovs, so if data in the iovs
> are valid, var_cnt should have been valid.
>
>     I worked around the issue for now by overriding the embedded
> pypy_setup.py file and re-calculating the value of var_cnt by assuming
> that
> parameters have iov_len > 0 and that (hopefully) there's no garbage in
> memory past the actual iovs.


Hi, from what you describe it looks like the uwsgi.h used by the pypy
plugin is different from the one used by the uWSGI binary. Can you try
forcing a rebuild of the cffi module ? (just remove the __pycache__
directory, or run uwsgi from another dir)



>
> Second issue:
>     I'm having very odd results with dictionaries used in my application.
> Even with "processes = 1", "enable-threads = false", "threads = 1",
> "offload-threads = 0" and "single-interpreter = true", some parts of my
> application are seeing different versions of the same dictionary.
>
>     In particular, I realised that any modifications done as a result of
> web requests (updating a dictionary from a POST request, for example), are
> somehow isolated from any modifications done as a result of background
> tasks (updating the same dictionary with information from a configuration
> file, for example). This does not make sense as when I print
> myDict.__repr__() in both places in my application, I get the same
> address.
> However, when I print myDict, the data is wholly different and
> independent.
>
> Other info:
>     The setup is on a Raspberry Pi running a custom Yocto-based
> distribution. uWSGI, nginx and pypy were cross-compiled from source. I do
> realise this complicates matters, but can anyone point out what could be
> amiss?
>

if you have some form of memory corruption, this could be related. I would
focus on fixing the first one.

-- 
Roberto De Ioris
http://unbit.it


More information about the uWSGI mailing list