[Twisted-Python] Using zeromq inside twisted matrix daemon

Uung H.R Bhuwono avenpace at gmail.com
Wed Jul 28 00:25:25 MDT 2010


Hi,

I've been trying to make use zeromq on my twisted daemon script
When zeromq send message to the queue, this work since send_pyobj()
return True.
But the subscriber never get the message from queue using recv_pyobj()
and it just freeze like there's nothing on the queue

My twisted daemon script as a follow:

- serve_message.py
class MyService(service.Service):
    def __init__(self):
        pass
    def startService(self):
        c = zmq.Context(1)
        s = c.socket(zmq.PUB)
        s.bind("tcp://127.0.0.1:6666")
        s.send_pyobj("helo there")
    def stopService(self):
        pass

def getMyService():
    myService = MyService()
    return myService

application = service.Application("My Service Application")

# attach the service to its parent application
procd = getMyService()
procd.setServiceParent(application)

my simple subscriber script subscriber.py

import zmq
c = zmq.Context(1)
s = c.socket(zmq.SUB)
s.connect("tcp://127.0.0.1:9999")
s.setsockopt(zmq.SUBSCRIBE, "")
s.recv_pyobj()

Does it possible to use zeromq with twisted daemon on Linux?
Please help me to solve this

Thanks,

Uung




More information about the Twisted-Python mailing list