Skip to content

Commit

Permalink
Drop tornado/twisted support
Browse files Browse the repository at this point in the history
Retargeting the project towards an async-only behavior.

Future-Proofing: As asyncio is part of the Python standard library, it's likely to receive continued updates and improvements.
By aligning with asyncio, we're ensuring that this project stays relevant and can benefit from the latest advancements in Python's asynchronous capabilities.
This also aligns with community momentum which heavily shifted towards asyncio for async operations while providing simplified maintenance and reduced dependencies by dropping two major frameworks.
  • Loading branch information
Mathias Brulatout authored and mbrulatout committed Dec 8, 2023
1 parent 21c5d60 commit 33e92de
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 895 deletions.
57 changes: 0 additions & 57 deletions consul/tornado.py

This file was deleted.

123 changes: 0 additions & 123 deletions consul/twisted.py

This file was deleted.

50 changes: 0 additions & 50 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,6 @@ library from the python standard lib, including the `requests`_ library can be
made non-blocking via monkey patching. This means the standard python-consul
client will just work asynchronously with `gevent`_.

Tornado
~~~~~~~

There is a `Tornado`_ client which makes use of `gen.coroutine`_. The API for
this client is identical to the standard python-consul client except that you
need to *yield* the result of each API call. This client is available in
*consul.tornado*.

.. code:: python
from tornado.ioloop import IOLoop
from tornado.gen import coroutine
from consul.base import Timeout
from consul.tornado import Consul
class Config:
def __init__(self, loop):
self.foo = None
loop.add_callback(self.watch)
@coroutine
def watch(self):
c = Consul()
# asynchronously poll for updates
index = None
while True:
try:
index, data = yield c.kv.get('foo', index=index)
if data is not None:
self.foo = data['Value']
except Timeout:
# gracefully handle request timeout
pass
if __name__ == '__main__':
loop = IOLoop.instance()
_ = Config(loop)
loop.start()
asyncio
~~~~~~~

Expand Down Expand Up @@ -124,11 +82,6 @@ result of each API call. This client is available in *consul.aio*.
loop.run_until_complete(go())
Wanted
~~~~~~

Adaptors for `Twisted`_ and a `thread pool`_ based adaptor.

Tools
-----

Expand Down Expand Up @@ -306,12 +259,9 @@ Consul.txn
.. _requests: http://python-requests.org
.. _Vanilla: https://github.com/cablehead/vanilla
.. _gevent: http://www.gevent.org
.. _Tornado: http://www.tornadoweb.org
.. _gen.coroutine: https://tornado.readthedocs.io/en/latest/gen.html
.. _asyncio.coroutine: https://docs.python.org/3/library/asyncio-task.html#coroutines
.. _aiohttp: https://github.com/KeepSafe/aiohttp
.. _asyncio: https://docs.python.org/3/library/asyncio.html
.. _Twisted: https://twistedmatrix.com/trac/
.. _thread pool: https://docs.python.org/2/library/threading.html

.. _ianitor: https://github.com/ClearcodeHQ/ianitor
3 changes: 0 additions & 3 deletions tests-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ pytest
pytest_asyncio
pytest-cov
pytest-rerunfailures
pytest-twisted
pytest-xdist
ruff
setuptools
tornado
tox
treq
twisted
virtualenv
wheel
6 changes: 3 additions & 3 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def test_node_meta(self):
c = Consul()
for r in _should_support_node_meta(c):
assert r().params == []
assert sorted(r(node_meta={"env": "prod", "net": 1}).params) == sorted(
[("node-meta", "net:1"), ("node-meta", "env:prod")]
)
assert sorted(r(node_meta={"env": "prod", "net": 1}).params) == sorted([
("node-meta", "net:1"), ("node-meta", "env:prod")
])


class TestMeta:
Expand Down
Loading

0 comments on commit 33e92de

Please sign in to comment.