[Zope-dev] Using Queue within a Zope product
Chris McDonough
chrism@zope.com
Tue, 15 Jan 2002 19:24:38 -0500
> I need to put messages into a queue from within a Zclass, and then get and
> process them from an external long running process.
When you say an external long running process, do you mean that you'll want
to access them from a separate process via something like XML-RPC? or ZEO?
Or HTTP? What is your preferred way to get access to the items in the
queue?
> I have created a class which imports a derivative of queue, the class
> instantiates a queue as a class object. The idea is that the queue will
use
> a persistent object for the queue (list), and then some external process
can
> also use the same object(list) in its queue processing. Both the zclasses
> that inherit from this queue and the external process must use the same
> mutexes...
I dont think you mean external process here, I think you might mean
something else... two processes can not share the same mutex. Do you maybe
mean thread?
> Questions:
> 1 Should the queue.queue object be made persistent or should we
instantiate
> it with an external list which is the persistent object. Can either of
these
> be done an how.
I think you could probably wrap the Queue class in a persistent wrapper...
that'd work. Anything that can be pickled can be made persistent, so as
long as the Queue class doesnt have a subobject that can't be pickled, you
can make it persistent. You'll need to write a Python product to do so (see
the Zope developer's Guide).
> 2. Assuming we can do something like the above what are the considerations
> wrt package distribution.
None, really... if you intend to share just the class data. If you intend
to share exports of instance data (the queues themselves), not much of an
issue here either... just need to make sure that each Zope you run on has
the Product you create.
HTH,
- C