From 23d4f5f396b79c48f496578509d0f1915078f292 Mon Sep 17 00:00:00 2001 From: Swen Kooij Date: Thu, 23 Jul 2020 09:51:17 +0300 Subject: [PATCH 1/2] Python 3.8 support (#2088) --- .travis.yml | 1 + docs/compatibility.rst | 2 +- requirements-dev.txt | 8 ++++---- setup.py | 1 + tox.ini | 8 ++++---- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e2fdfedf..bfbae5721 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ python: - 2.7 - 3.4 - 3.7 + - 3.8 - pypy2.7-6.0 env: diff --git a/docs/compatibility.rst b/docs/compatibility.rst index 93be6fd6e..ae152618e 100644 --- a/docs/compatibility.rst +++ b/docs/compatibility.rst @@ -16,6 +16,6 @@ Although kafka-python is tested and expected to work on recent broker versions, not all features are supported. Specifically, authentication codecs, and transactional producer/consumer support are not fully implemented. PRs welcome! -kafka-python is tested on python 2.7, 3.4, 3.7, and pypy2.7. +kafka-python is tested on python 2.7, 3.4, 3.7, 3.8 and pypy2.7. Builds and tests via Travis-CI. See https://travis-ci.org/dpkp/kafka-python diff --git a/requirements-dev.txt b/requirements-dev.txt index 77b8b5134..d2244a965 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,6 @@ flake8==3.4.1 -pytest==3.10.0 -pytest-cov==2.6.0 +pytest==5.4.3 +pytest-cov==2.10.0 docker-py==1.10.6 coveralls==1.5.1 Sphinx==1.6.4 @@ -9,8 +9,8 @@ xxhash==1.3.0 python-snappy==0.5.3 tox==3.5.3 mock==3.0.5 -pylint==1.9.3 -pytest-pylint==0.12.3 +pylint==2.5.3 +pytest-pylint==0.17.0 pytest-mock==1.10.0 sphinx-rtd-theme==0.2.4 crc32c==1.7 diff --git a/setup.py b/setup.py index 8bc484c9a..005c5adb7 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,7 @@ def run(cls): "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", ] diff --git a/tox.ini b/tox.ini index 596a9f211..10e9911dc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{26,27,34,35,36,37,py}, docs +envlist = py{26,27,34,35,36,37,38,py}, docs [pytest] testpaths = kafka test @@ -8,10 +8,10 @@ log_format = %(created)f %(filename)-23s %(threadName)s %(message)s [testenv] deps = - pytest<4.0 + pytest pytest-cov - py{27,34,35,36,37,py}: pylint - py{27,34,35,36,37,py}: pytest-pylint + py{27,34,35,36,37,38,py}: pylint + py{27,34,35,36,37,38,py}: pytest-pylint pytest-mock mock python-snappy From 21b3cb25df0b774bb255eef98bce32a474eba11a Mon Sep 17 00:00:00 2001 From: Orange Kao Date: Thu, 23 Jul 2020 02:43:45 +0000 Subject: [PATCH 2/2] Avoid 100% CPU usage while socket is closed After stop/start kafka service, kafka-python may use 100% CPU caused by busy-retry while the socket was closed. This fix the issue by unregister the socket if the fd is negative. --- kafka/client_async.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kafka/client_async.py b/kafka/client_async.py index 5379153c2..4a78d417b 100644 --- a/kafka/client_async.py +++ b/kafka/client_async.py @@ -635,6 +635,9 @@ def _poll(self, timeout): self._sensors.select_time.record((end_select - start_select) * 1000000000) for key, events in ready: + if key.fileobj.fileno() < 0: + self._selector.unregister(key.fileobj) + if key.fileobj is self._wake_r: self._clear_wake_fd() continue