Get these files on your machine.
$ pip install uvicorn$ uvicorn app:chat_server -w 3-
If you know what uvicorn is, skip to 2. Else, open (https://github.com/tomchristie/uvicorn) in a background tab while I tell you how brilliant this new project is. It takes several well established ideas and implements them fresh with absolutely no fluff.
1.1 Uvicorn is a ridiculously fast http and websocket framework.
1.2 Write asynchronous worker functions using Python's async/await.
1.3 Uses ASGI, a protocol championed by django-channels.
1.4 It can use a redis server to go async + parallel = ridiculous * hahahamadness! fast.
1.5 Deploy it behind a hardened proxy/forwarding server.
-
You want to run your brand new uvicorn project on a small VPS?
2.1 You want to run redis as a unix service.
2.2 You don't want to manage another dependency.
2.3 You don't need redis for anything else.
-
Redislite to the rescue! (https://github.com/yahoo/redislite)
3.1 Redislite bundles redis with the pip-installable package.
3.2 It runs the embedded redis with network access disabled.
3.3 It can monkey patch existing redis using libraries.
-
This gist implements the solution to the problem and available options explained above :)
4.1 Yep, it builds on code from uvicorn's own examples.