You are probably best off using an existing protocol like XMPP . For example, for Plone (Python CMS), there is full XMPP integration with collective.xmpp.chat , which provides multi-user chat and instant messaging between authenticated users of the Plone website ( demo video ).
For Pyramid, you need to complete this integration yourself [1] by starting the Jabber / XMPP server (eg ejabberd ) and using the existing XMPP client library to communicate with Python. There are many XMPP libraries for Python, some of which are described in the answers to this question .
Note Don't be afraid if it looks complicated after watching XMPP. XMPP and its extension describe a wide range of features related to Messaging and Presence, chat is just one of them. If you do not need other functions, just do not execute them in your web application.
[1] There is actually a Pyramid project that seems to be doing just that: seshat , written by @KirkStrauser. I have not used it myself, but it looks very promising.
source share