[zeromq-dev] 0MQ 1.0.1 Python Global Interpreter Lock patch?
Martin Sustrik
sustrik at fastmq.com
Tue Oct 20 12:23:04 CEST 2009
Aamir M wrote:
> Hi Ben,
>
> In regards to the code review that you mention, did you have a look at
> txAMQP by any chance? txAMQP is a new Python client for AMQP based on
> the Twisted framework. There is an interesting discussion about it at
> http://www.apparatusproject.org/blog/2009/04/creating-a-simple-amqp-client-using-txamqp/
> ...
>
> Specifically the author claims that, "Being event-driven is important
> when implementing AMQP in your project, because it creates a
> concurrency model using non blocking calls." So he is against using
> blocking calls and instead prefers to use callbacks. And apparently
> the Twisted "concurrency model" consists of polling for messages and
> then going sleep for some amount of time, then polling again .... That
> sounds quite inferior to the concurrency model that we have with 0MQ
> (i.e. making 0MQ blocking calls, wrapped with Py_BEGIN_ALLOW_THREADS /
> Py_END_ALLOW_THREADS).
Yup. I don't like callbacks myself as they tend to make the application
code messy.
As for sleeping and checking whether there are messages available would
have grave impact on message latency. Still, you can use 0MQ that way if
you wish (sleep + non-blocking receive).
Moreover, in 0MQ/2.0 (trunk) there's new zmq_poll function that allows
for waiting for activity on multiple 0MQ and POSIX sockets. That should
solve the non-blocking scenario in a sane fashion.
Martin
More information about the zeromq-dev
mailing list