[Twisted-Python] Integrating Twisted with ZeroMQ
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Sun Jun 6 23:16:12 MDT 2010
On 04:54 am, exarkun at twistedmatrix.com wrote:
>
>[snip]
>
> from twisted.internet.interfaces import IReactorFDSet
>
> class ZMQTransport(object):
>[snip]
>
>
> class _ZMQFileDescriptor(object):
>[snip]
> def sendZMQEvents(self, events):
> # Whatever the API is.
> self._zmqSocket.sendZMQEvents(events)
> self._reactor.addWriter(self)
The sendZMQEvents method clearly belongs on ZMQTransport. This
complicates the `addWriter` call slightly - but only to the extent of
either selecting the correct _ZMQFileDescriptor to pass, or more likely
just looping over all of them and calling addWriter for each. Hopefully
the idea was clear despite this mistake.
>[snip]
>
> def connectZMQ(reactor, addrinfo, factory):
>[snip]
Also, I meant to mention here that it doesn't really matter if this is a
connectXYZ-style function or something using endpoints. That's just a
minor API question and all the other ZMQ-related stuff is the same
whichever decision you make.
Jean-Paul
More information about the Twisted-Python
mailing list