python-zk / kazoo

Kazoo is a high-level Python library that makes it easier to use Apache Zookeeper.
https://kazoo.readthedocs.io
Apache License 2.0
1.3k stars 387 forks source link

gevent private API dependency breaks import #505

Closed emmettbutler closed 6 years ago

emmettbutler commented 6 years ago

Description

After gevent's 1.3.0 release, importing kazoo.gevent.SequentialGeventHandler breaks with AttributeError: 'module' object has no attribute 'Timeout'.

What I've run

In a freshly created virtualenv:

$ pip install kazoo==2.4.0 gevent==1.3.0
...
Successfully installed gevent-1.3.0 greenlet-0.4.13 kazoo-2.4.0 six-1.11.0
In [1]: from kazoo.handlers.gevent import SequentialGeventHandler
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-31acaf3fc700> in <module>()
----> 1 from kazoo.handlers.gevent import SequentialGeventHandler

/home/emmett/virtualenvs/kazoo-bug-test/lib/python2.7/site-packages/kazoo/handlers/gevent.py in <module>()
     30 
     31 
---> 32 class SequentialGeventHandler(object):
     33     """Gevent handler for sequentially executing callbacks.
     34 

/home/emmett/virtualenvs/kazoo-bug-test/lib/python2.7/site-packages/kazoo/handlers/gevent.py in SequentialGeventHandler()
     61         self._workers = []
     62 
---> 63     class timeout_exception(gevent.event.Timeout):
     64         def __init__(self, msg):
     65             gevent.event.Timeout.__init__(self, exception=msg)

AttributeError: 'module' object has no attribute 'Timeout'

Related issue on gevent: https://github.com/gevent/gevent/issues/1205 - apparently this is due to gevent.event.Timeout not being part of the public API that is guaranteed to not break across minor versions.

Related issue on pykafka: https://github.com/Parsely/pykafka/issues/801 - this issue has forced users to manually pin gevent versions as a workaround.

emmettbutler commented 6 years ago

Just noticed this was fixed in master. https://github.com/python-zk/kazoo/commit/257b58961f7ddd9db04d6efa070739a1b0404487

farshidce commented 6 years ago

are you planning to create a new tag/release 2.4.x with this change soon :) ?