0MQ with green thread?

I grew up to like erlang and it is a wonderful (coughing) architecture appropriate to my problem. In the meantime, I still like to think that I can clone erlang processes and the asynchronous message passed to python (I'm currently in therapy to get rid of this obsession).

During a recent revelry, I came across 0MQ and I like its messaging features. This may be obvious to the erlang / OTP expert, but I'm just a modest python programmer (my shrink will no doubt read this clever argument). The 0MQ user-guide claims that it uses native OS threads, not virtual green threads.

  • Is there a way to make 0MQ work with saylet / gevent?

  • Or should I avoid green-eyed monsters and stick to one Python application thread, with non-blocking I / O processed by the 0MQ message queue, and my own (qualified) use of my own threads?

  • Or, check out rehab and get back to erlang?

+7
erlang zeromq
source share
2 answers

Answering a simple thread, because I'm kind of in the same boat. I thought I would share my thoughts.

1: it looks like all the heavy operations have already been done: https://github.com/traviscline/gevent-zeromq integrated the gevent loop with the non-blocking zmq connector and even some Cpython accelerations. It also seems (at the time of this writing) to be sufficiently substantiated.

2: It depends; if you are writing something that zmq can use without a ton of external event logic, then you should just use zmq. If you need to integrate OTOH with other protocols, you can use gevent (or perhaps twisted, although it does not have a working zmq at all). My projects usually require several protocols (i.e.: private queue manager, public http, public https, private memcache, etc.), so I am exploring switching to gevent to convert the project more quickly than my current favorite: twisted.

3: You can completely skip zmq and integrate with your existing erlang-based solution like rabbitMQ; zmq performance benefits may not be as important as you think, and then you have an erlang message queue that integrates easily with python with existing libraries.

Also see: Comparing Messsage Queues in the Second Life Wiki

+3
source share
+2
source share

All Articles