44

I have an installation of uWSGI that is running in emperor mode. Vassals are using different python versions, so I can't have a Python plugin embedded in uWSGI binary.

Having said that, I want to use asyncio loop engine in one of vassals, but I can't figure it out how to run asyncio plugin and greenlet plugin that are not embedded.


What I've tried so far:

  • Embedding asyncio and greenlet into uWSGI, using:

     CFLAGS="-I/usr/local/include/python3.4" make PYTHON=python3.4 asyncio
    

    to build uWSGI. But that will also embed python plugin and I don't want it.

  • Building asyncio and uWSGI as external plugins using:

     PYTHON=python3.4 ./uwsgi --build-plugin "plugins/greenlet greenlet"
     PYTHON=python3.4 ./uwsgi --build-plugin "plugins/greenlet greenlet"
    

    to build plugins, but that plugins will fail to load with:

    /usr/local/lib/uwsgi/asyncio_plugin.so: undefined symbol: up
    /usr/local/lib/uwsgi/greenlet_plugin.so: undefined symbol: up

    in logs.

    // Edit
    I've figured out that python plugin must be enabled before asyncio and greenlet in settings, so error is not occuring anymore, but greenlet is not working, there is no parent in current greenlet.

What else can I try to do? I bet that embedding asyncio and greenlet in python3.4 plugin will work, but I don't know how to do it or if it is even possible.

Currently I'm using second emperor with built-in required plugins, but I can't use that solution any longer due to limitations of platform.

Diggy.
  • 6,744
  • 3
  • 19
  • 38
GwynBleidD
  • 20,081
  • 5
  • 46
  • 77
  • 1
    I don't follow why do you need *asynchronous* asyncio inside *synchronous* uWSGI? – Andrew Svetlov Dec 18 '15 at 12:24
  • 1
    @AndrewSvetlov uWSGI is not only synchronous. It may be confusing, but uWSGI can also handle asynchronous applications, see [this example in docs](http://uwsgi-docs.readthedocs.org/en/latest/articles/OffloadingWebsocketsAndSSE.html). I need asynchronous uWSGI server for websockets, just like in this case, but I also need some features (mostly third party libraries) from asyncio (example is based on gevent). – GwynBleidD Dec 18 '15 at 14:25
  • You could also run an additional emperor, and have them monitor different directories - we do it to run CPython and PyPy apps under emperor, that are also incompatible. – Konstantin Lopuhin Dec 18 '15 at 15:01
  • @KonstantinLopuhin actually, you can deal with CPython and PyPy in one emperor using uwsgi binary without built-in python plugin. That way one of vassals can use PyPy plugin and other CPython. I'm aiming for that behaviour with asyncio, but no success yet... – GwynBleidD Dec 18 '15 at 15:47
  • I'm having success rewriting the pypy plugin and the asyncio event loop in Python+cffi, minus a few details. https://github.com/unbit/uwsgi/pull/2170 – joeforker Jun 01 '20 at 02:59

1 Answers1

1

I believe you should follow the approach outlined here: https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#bonus-multiple-python-versions-for-the-same-uwsgi-binary

Basically:

  • Build a core uwsgi binary that does not have the Python plugin (to be used by the emperor): make PROFILE=nolang
  • And then build plugins for each python version that you use (for the vassals), and configure each vassal to use the correct plugin.
codeape
  • 97,830
  • 24
  • 159
  • 188
  • 2
    Yes, that's the approach I was trying to follow. The problem is somewhere else: I can't specify 2 plugins for a single vassal and I can't figure out a way to combine python and greenlet plugins into one plugin. I've moved away from the emperor/vassal approach and I'm using separate uWSGI services managed by systemd, but it would still be nice to find a solution. – GwynBleidD Sep 22 '21 at 13:12