Kafka integration with asyncio
Project description
asyncio client for Kafka
AIOKafkaProducer
AIOKafkaProducer is a high-level, asynchronous message producer.
Example of AIOKafkaProducer usage:
from aiokafka import AIOKafkaProducer
import asyncio
async def send_one():
producer = AIOKafkaProducer(bootstrap_servers='localhost:9092')
# Get cluster layout and initial topic/partition leadership information
await producer.start()
try:
# Produce message
await producer.send_and_wait("my_topic", b"Super message")
finally:
# Wait for all pending messages to be delivered or expire.
await producer.stop()
asyncio.run(send_one())
AIOKafkaConsumer
AIOKafkaConsumer is a high-level, asynchronous message consumer. It interacts with the assigned Kafka Group Coordinator node to allow multiple consumers to load balance consumption of topics (requires kafka >= 0.9.0.0).
Example of AIOKafkaConsumer usage:
from aiokafka import AIOKafkaConsumer
import asyncio
async def consume():
consumer = AIOKafkaConsumer(
'my_topic', 'my_other_topic',
bootstrap_servers='localhost:9092',
group_id="my-group")
# Get cluster layout and join group `my-group`
await consumer.start()
try:
# Consume messages
async for msg in consumer:
print("consumed: ", msg.topic, msg.partition, msg.offset,
msg.key, msg.value, msg.timestamp)
finally:
# Will leave consumer group; perform autocommit if enabled.
await consumer.stop()
asyncio.run(consume())
Running tests
Docker is required to run tests. See https://docs.docker.com/engine/installation for installation notes. Also note, that lz4 compression libraries for python will require python-dev package, or python source header files for compilation on Linux. NOTE: You will also need a valid java installation. It’s required for the keytool utility, used to generate ssh keys for some tests.
Setting up tests requirements (assuming you’re within virtualenv on ubuntu 14.04+):
sudo apt-get install -y libsnappy-dev libzstd-dev libkrb5-dev krb5-user make setup
Running tests with coverage:
make cov
To run tests with a specific version of Kafka (default one is 1.0.2) use KAFKA_VERSION variable:
make cov KAFKA_VERSION=0.10.2.1
Test running cheatsheat:
make test FLAGS="-l -x --ff" - run until 1 failure, rerun failed tests first. Great for cleaning up a lot of errors, say after a big refactor.
make test FLAGS="-k consumer" - run only the consumer tests.
make test FLAGS="-m 'not ssl'" - run tests excluding ssl.
make test FLAGS="--no-pull" - do not try to pull new docker image before test run.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for aiokafka-0.10.0a0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31332a09512f2a2e133a35befe71ddb82fed99f399951fb26030496c574b746 |
|
MD5 | 01b698f4756c6f62f53a979ea54e61a4 |
|
BLAKE2b-256 | b2e47354358edb2718feee171d136eb6ac77c355bb88779259399f3c865f918b |
Hashes for aiokafka-0.10.0a0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91f6587722a171d1adbd973969ed34264f0779ee1522446b486bff46889ce966 |
|
MD5 | bf28ee6b6cac69d869760431cf174123 |
|
BLAKE2b-256 | 514547e86cbdc5c8e5c8647a7ee5d83c1ee277d327e16d9b98be8148a02e2720 |
Hashes for aiokafka-0.10.0a0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 763556b0d8820a94ec5f12f1ea934c2ccf7f71853d02b81841a2d6a265c501bb |
|
MD5 | ceb6acc00856ad622ea2f18f9bf8292b |
|
BLAKE2b-256 | ec9f6e17ad0c9f152c80191b7a6bc7ed2e05dfdf71cbb53aeda77366ede698ee |
Hashes for aiokafka-0.10.0a0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0bba3f2772734c878e86490c21c0bad1be0874fe02f3bd192717c3870608516 |
|
MD5 | bd5aae6f0cc71657611beda0a8f33535 |
|
BLAKE2b-256 | 2f0f408ec4271c05e85426495b4d74fccd9df508b7a6bc3a83c1d5988ee6b7a0 |
Hashes for aiokafka-0.10.0a0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1cd29b4101c15731f05480789e17a1456fd87a68cf9af176511280b1baf10d3 |
|
MD5 | f50344ed513a4c4995614afc08312bfc |
|
BLAKE2b-256 | be5fbb60275c60497bcfa16dc780d1589c99db3d1ec5462d20b5118513736213 |
Hashes for aiokafka-0.10.0a0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc0aba857ff904ad3d8255896e9787bcd1bfcf69f8df458033cc2ee504c747a1 |
|
MD5 | 4da6f67a5fb311b1bd592f4f18748d3d |
|
BLAKE2b-256 | f254381518ab0eeb92ca3f043930e8da1e9d5c7165e063a267ab09930cf2d1e4 |
Hashes for aiokafka-0.10.0a0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 481696274b186e1e70a5ca68ec781fcc05357cca91a0b4c745b13f10f369d405 |
|
MD5 | 8b6c2d9c598233d71e700b8951e7180c |
|
BLAKE2b-256 | 82b642b4e43581319c15be8df5ab6212b63c245efcb63facf19cb0de85886f58 |
Hashes for aiokafka-0.10.0a0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc776997bb3ee4c4a0dbb064c4694cc1006661324b1d66ca3cf1d7a1091e8d50 |
|
MD5 | a3478ca2d837a90683934ab683d845c2 |
|
BLAKE2b-256 | 458b9352916840b1bdece240b7a45ec236e9ef4f6aeff582d4607cd4673c6d17 |
Hashes for aiokafka-0.10.0a0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29a3a6ff4eddcd680299ede1c40c63ede7445668ade09f39148c4f4cd349f85d |
|
MD5 | 0280a80e2bb165c3bb6283724bb75f9c |
|
BLAKE2b-256 | 03c4411c54c3054529095b3ccf1d19e8d47efd548d25dc67abbf13d0b5cfd183 |
Hashes for aiokafka-0.10.0a0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d8572c7abfa45eac3917d3d143a739746227d390dc5f72cf742f23e01ad3aac |
|
MD5 | d7f0414ddc6ffbc8374c87be6dbf07c0 |
|
BLAKE2b-256 | eaf6d61b8df5b04539d5abd966515e619d77f618aa65b8f25cf7daae0f53b5b6 |
Hashes for aiokafka-0.10.0a0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81aaa3c0019a31b9feea331315dc1437c3b988c1f5d22c27579a949e2ad839ee |
|
MD5 | 732028a10b5a2be2ce257c6cfea5577a |
|
BLAKE2b-256 | 9a7023462dd0468489b9465a8f6b758b441cb2683c82419c250ff1fdcd9f5486 |
Hashes for aiokafka-0.10.0a0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c2244f6e111769e4e464a1c82815ef3e740cf09e4db489a662a3c3189e83bbe |
|
MD5 | ef1cbf5434cf613eb06059799eb20879 |
|
BLAKE2b-256 | 09a388a25594f9573b72004ac1d3aec608048fed7b3889d6df9280543664e337 |
Hashes for aiokafka-0.10.0a0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dd8da4d69893a2d647c15e2fa88b9856c21de7cb1176c879a723f8ff7e2a55b |
|
MD5 | 09b9e6217c70627c97d0a1749a706eae |
|
BLAKE2b-256 | cf2a6b951b47193b480c1d028a2b23e17fb78e757ec022c69b77f451a0a1962e |
Hashes for aiokafka-0.10.0a0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49ff256fae7482b144fe0d6ae8ed1b62b87a4fb80a84f3734511bf8bd9338af9 |
|
MD5 | 6862c22aedf2fc3bd36ba5c2bc4756b0 |
|
BLAKE2b-256 | 8bb8f2a6d71ac7785975b69f2d4f8f06ee3a6e1fb77a126e43ac2e0eaff85056 |
Hashes for aiokafka-0.10.0a0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b3b6f97be2775e97a20502325dfac7208f32362311bed0643ccf9bade79021 |
|
MD5 | 613550a0950169dd65524683cb76008c |
|
BLAKE2b-256 | 55f46c058975251cd4d039ba8cc9db6395eaebbb6c30b0f13974c4715f150795 |
Hashes for aiokafka-0.10.0a0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c1c38d6e8eaead12a2e813b0e4e30016c207be87721fab464da34a41d8f3732 |
|
MD5 | e808c9a027973421ee0e1a55794fc092 |
|
BLAKE2b-256 | 3a7f329b7d87d4b8bf3799c6c7815122271e6da3e195c8d8c19ab07be153b0f2 |
Hashes for aiokafka-0.10.0a0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aab4b37f5cfe48fc04a14a2d412deedaae3e5527296ad5c5a4bf5ed85967c138 |
|
MD5 | 5de91f37b71e8b46b0192d290379e831 |
|
BLAKE2b-256 | 98ebac17ea3554cae7e7cc878cfa3ee6272268bc80b5f51f0a707667a17d3cd1 |
Hashes for aiokafka-0.10.0a0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dafc9dc758569c0138536f7049b9daec7dd8e65b4f72fd009124305e0eaa7ca |
|
MD5 | 8bf1f885bf4fe6cadfc89ee4eac40059 |
|
BLAKE2b-256 | d79454a88993feba9e9167a08e597974e4d9308143b3c67cac637e766b6fc99f |
Hashes for aiokafka-0.10.0a0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 465a7f1f78eaf32b1e042bf663e321733b7b981ae6b359898a837864c412fbcf |
|
MD5 | 7bbdf0f2a4a5753e1a9fe9af2bb7598a |
|
BLAKE2b-256 | b59b0bf6d603cd5a63d391d9c036e4e1011b6f15a0876365a5a2e9f8d5c116e2 |
Hashes for aiokafka-0.10.0a0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 289236959ba964c9acfb34ed5f20b515e124bd07fba76beb883485b82a64fafd |
|
MD5 | 853455d515789d669aaea5cd9d5a4744 |
|
BLAKE2b-256 | 048d53b05c78710a3d6ca195f45c7d8b95d6d4eaab732e86df9bd161f49877d3 |
Hashes for aiokafka-0.10.0a0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd39e650546754eaf28c9dc2a5fd27e65b15160a401ab597ad07f8af5abb91c3 |
|
MD5 | c8c7ba16f57d2b774e67d6c69386c240 |
|
BLAKE2b-256 | 31aa079f9d3da51d9ef1ec2e8324ff59b34de95b4870deedb98939c2925c31ed |
Hashes for aiokafka-0.10.0a0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6345d88ec78005df43aa947ba0c38b5debd9fd06950413bf1b77e5141f932688 |
|
MD5 | 74a525ed9c8bdd61ec47d1c63d81a2d1 |
|
BLAKE2b-256 | 0b6ed7d6439c4b869d4ab9e08e9291962245160acc9711176b3b019b787bd53a |
Hashes for aiokafka-0.10.0a0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e4451ef6af95b02e5f55aaf9ca438be8e3b7a885e494bc6bccabb693d699612 |
|
MD5 | 94633e0026090840c19db53432cb7c21 |
|
BLAKE2b-256 | b161ff6a18932fa0aaca593a99e2f960ffbd38500fae65b95e8ea512ee10673d |
Hashes for aiokafka-0.10.0a0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24b515d64bac603fc5088e1f56bb62ea391ffe93232ae8dc725384bac73c55e4 |
|
MD5 | 8960d8a8f5f2bf0336944109e1ec2293 |
|
BLAKE2b-256 | 87a3c5583f3292482106e3c4883e567e27becc6d1f97197ae6f62630fe96a744 |
Hashes for aiokafka-0.10.0a0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77312f9e8dccdd3bd9525d7c431626485f6aefc3e506f6ff6181f84e94969a4a |
|
MD5 | 647e7763bd1380e280808dbe7b772e74 |
|
BLAKE2b-256 | 733d0b9bf9469ad723dabcb43358bf2f0fa4beac898720dd6a537f7dc2122a94 |
Hashes for aiokafka-0.10.0a0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fbc3844671dc41ca388e6c7d4fe4cf4953c818868231bfb6c38699e49453393 |
|
MD5 | bdb2f5b82a04281441057715cc830a45 |
|
BLAKE2b-256 | 769c26868dfea71d80a7c2f2412f54f004ca7b7620af2f55406946552901a6ea |
Hashes for aiokafka-0.10.0a0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3b2e58a9297a7fa4a91c3a7a4f79aaba4a4470a211b02e31f9e7e5e2890ebe1 |
|
MD5 | 30bbaa8723e0bc709551217e9c92b303 |
|
BLAKE2b-256 | 20c73337053b67e422308f5feb93844521f7f036ff046a88a952f62ddd154b92 |
Hashes for aiokafka-0.10.0a0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c61226ec565001febd1a1dfde532863a69d578fbe78162b5bc779c6ccfc4d41 |
|
MD5 | 987f39760bf10a49c5ff69c538a4974d |
|
BLAKE2b-256 | 7a9e40671ae1eda2ec3b41c9e444b0d18cfa8376f70d76a267967ae7abb2c671 |
Hashes for aiokafka-0.10.0a0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 643f06b93a6610649bdf3ef891a8b6389a95b83e6e670ff5527bce2db666c293 |
|
MD5 | 43ef016b3bf4102e75c8bd5a7458cac2 |
|
BLAKE2b-256 | b7f44265d3f1becf8c4584d49f9d6c6f19038925b33e2eea5a53d4ce2a30c706 |
Hashes for aiokafka-0.10.0a0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88b0fef4fa5067d8cc9e861d0de4579719a3cf6c1a5381a6fc1d0993a50be302 |
|
MD5 | 52e74158dbeffd636ea0004f55a5a3e4 |
|
BLAKE2b-256 | f62439809c29c5a2ceba40b8e8f693dff47eeeb9069c3ce5c25a1fbf71e56f4e |