[Zope-dev] Queue object in Zope products
Joost van Lawick
Joost van Lawick <joost@lawick.nl>
Thu, 24 Oct 2002 10:05:38 +0200
Hello,
I am working on a Zope product that throws data into a queue that is monitored
by a number (3) of producers. Producers can talk to Corba objects. I use
omniOrb for this. Producers take out data from the outqueue and send it to other
Corba objects. This is the basic setup:
class SIPConnector(SimpleItem):
"""Connector class"""
def __init__(self, id, title):
self.id = id
self.title = title
self.n = 3 # number of producers
def initConnectionPool(self):
self._v_outqueue = Queue.Queue()
for i in range(self.n):
id = 'tc' + str(i)
tp = SIPProducer(id)
thread.start_new_thread(self.runProducer, (tc, self._v_outqueue,))
def post(self, sid, to, msg):
self._v_outqueue.put(sid, to, msg)
def runProducer(self, tp, oq):
# connect to Corba dispatcher
tp.orb, tp.cmf = tp._connect()
while 1:
try:
msg = oq.get(0)
print msg
tp..cmf.xmit(msg)
except Queue.Empty:
time.sleep(0.05)
class SIPProducer(CorbaBaseClass):
def __init__(self, id):
self.id = id
This basically works. However, if I put msg's in the queue with the post method from a page template, and I do this a couple of times, quickly, I get an attribute error on self._v_inqueue. It is somehow gets lost. Does anyone know what I am doing wrong here? What happened to the 'lost' queue?
Cheers,
Joost
--
Brain, v. [as in "to brain"]:
To rebuke bluntly, but not pointedly; to dispel a source of
error in an opponent.
-- Ambrose Bierce, "The Devil's Dictionary"
--
Joost van Lawick van Pabst
E: joost@lawick.nl
W: http://www.lawick.nl/