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

why not support "Asyncio handler" #499

Closed EchoShoot closed 1 year ago

EchoShoot commented 6 years ago

I sincere recommend kazoo to support asyncio handler, your know twisted can be transform object from asyncio , in the future, may more and more Asynchronous framework can be transform object from asyncio! i meaning that it will support a lot of frameworks if kazoo support asyncio!

-- your loyal fans

tonyseek commented 5 years ago

The current implementation of connection routine uses blocked-style handler.select. It works well with monkey patch based solutions but does not work with asyncio.

In my opinion, this is a price for that asyncio chooses to use explicit scheduling and introduces new backward-incompatible syntax. So many libraries are hard to adapt asyncio without breaking Python 2.x users. Even the standard DBAPI2 and WSGI libraries could not be adapted too until new PEP was published. Adapting native asyncio means maintaining a standalone branch for Python 3.x users only, just like what Gunicorn do.

For Kazoo, using the threading handler in Python 3.x and asyncio may be fine enough, since Python 3.x has resolved the performance problem of GIL when multi-threading is enabled. The background kernel thread to maintain ZooKeeper connection avoids starving caused session expired also.