Question

I'm trying to build a Pyramid app that uses ZeroMQ to provide a very simple chat/messaging interface, but I can't seem to figure out the proper setup/workflow.

The structure seems straightforward enough to me, and in its simplest form could be described in as little as two Pyramid "views"/routes:

  1. The client SSE "show messages" view: This view/route would remain open to the client (using Server-Sent Events on the client-side and Pyramid's response.app_iter on the server-side), listening for messages from ZeroMQ and yielding them up to the client as they are received.
  2. The "submit a new message" view: This view/route would receive POST requests containing a single message's data, which it would then pass to ZeroMQ to be received in the SSE view and displayed to any clients listening there.

For some reason however, I have not been able to come up with the correct recipe for accomplishing this feat. Google seems to be pretty sparse when it comes to recipes for 0MQ and Pyramid, and all of my own hacking has either resulted in Python/Pyramid thread/process problems, or 0MQ never being able to send or receive any messages (which is probably related to my threading issues).

So, how does one properly build this kind of an app with Pyramid?

P.S. You may assume any version of Python/Pyramid, etc in your answers. The point is to just get something that works as described.

Was it helpful?

Solution

I made a proof of concept of exactly that a few years back.

https://github.com/antoineleclair/zmq-sse-chat

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top