[pypy-dev] cffi embedding interface uwsgi plugin

Daniel Holth dholth at gmail.com
Wed Apr 22 22:31:03 EDT 2020


I'm playing with the cffi embedding interface. I dusted off the uwsgi pypy
plugin and began porting it to the new interface. I'm very impressed at how
little C is required to make it work.

The Python code embedded in the module, that attaches Python functions to
uwsgi's plugin interface with @ffi.def_extern(), could be replaced with
"import <module passed as uwsgi argument>" and you could iterate on this
without (the 1-second of) recompiling each time. A suitably motivated
person could build an ASGI server this way.

Need to look up how to initialize virtualenv at the Python level. I had
more success with pypy 7.1.1 which seemed to be finding the virtualenv
based on the working directory. Currently pypy 7.3.1 is having trouble
finding the os module in pypy_init_home. And this patch
https://foss.heptapod.net/pypy/cffi/issues/450 is needed to get rid of a
warning.

When it works the cool demo would be to compile suffixed variants of the
plugin for pypy and cpython, having one uwsgi emperor mange servers in both
languages.

It's at https://github.com/unbit/uwsgi/pull/2146/files

Cheers,

Daniel Holth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20200422/1b0d4223/attachment.html>


More information about the pypy-dev mailing list