Ben Bangert 2012-05-17, 00:50
Mark Gius 2012-05-17, 16:24
Ben Bangert 2012-05-17, 21:41
Alan D. Cabrera 2012-05-18, 03:24
Mark Gius 2012-05-18, 17:11
Alan D. Cabrera 2012-06-03, 17:44
Patrick Hunt 2012-05-17, 22:46
Martin Kou 2012-05-20, 19:29
Ben Bangert 2012-05-21, 19:58
-Re: The State of Python Zookeeper libraries and collaboration
Mark Gius 2012-05-21, 20:23
On Mon, May 21, 2012 at 12:58 PM, Ben Bangert <[EMAIL PROTECTED]> wrote:
> On 5/20/12 12:29 PM, Martin Kou wrote:
> > A pure Python implementation shouldn't be needed for gevent. It should be
> > sufficient to run the Zookeeper client in async mode in a background
> > (with mt or st.. personally I prefer st), and then use an eventfd() or a
> > pipe() to notify gevent.
> > In fact, if you look into gevent's thread pool library - they're using
> > libev's async signal which is also based on eventfd() and pipe(). So it's
> > not a new trick.
> The current kazoo implementation uses something like this to pass off
> the events. Also, under a test script, it *seems* to work if the ZK
> thread plants a lambda onto a gevent Queue for a gevent greenlet worker
> to then execute.
> Here's an example script testing it (when the use_gevent is set to
> False, the other greenlet fails to print as its using a blocking Queue
> of course):
> I haven't tried this out with the Python ZK lib, do you know offhand if
> this is going to run into any issue with gevent having a problem with
> items being added to its queue from the other thread?
> I'd like to avoid the extra complexity of the pipe's and such if this is
> going to work (which the test script seems to). I was also going with
> this approach to ensure sequential watch execution when used with gevent
> (and the watch func could spawn itself as a new greenlet if it needs to
> yield, etc.)
> Ben Bangert
> (ben@ || http://) groovie.org
+1 on avoiding complexity, and wrangling python_zk so that it behaves with
eventlet/gevent is very complex.
The advantage of a pure-python client is that we don't have to play these
tricks to deal with the fact that the multithreaded library produces
Threads which are not Green safe, causing us to play games to ship code
back into a green thread.
The other trick is that there are more than one "green thread" libraries
out there. gevent, eventlet, twisted, etc. A pure python implementation
means that we don't have to special case for various libraries. eventlet
just has to monkey patch the standard library, same with whatever gevent or
I'm happy to help with a client that interfaces with the C bindings, but I
think that a pure-python client would be cleaner and support a wider
variety of deployments.
Duncan Findlay 2012-05-22, 04:17