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.9.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91e3ec7b22b09ed51c0bcad72b1b599dae2455f83912881fed24c3abe4198c3e |
|
MD5 | 24585a917366d5e6c7ad743381c090ac |
|
BLAKE2b-256 | d1f5d7fe10de4438259c26e1734ac4cb25595c02c1fcc3e0d5c99d0dfc640278 |
Hashes for aiokafka-0.9.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fff7cd498f31ff69e450b272d76b20776bef17bf17beae43a465c3f07983a5c |
|
MD5 | c707c70e17decb35e7aaa5a4b3a2c414 |
|
BLAKE2b-256 | cd18c4887c668ee79019d302295861595b34ee99a31c6083490d9022b0258831 |
Hashes for aiokafka-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d8b9bc181bd8d65f9529d7eaf60cf0ba6982bc33a2a0bccb2833d2b41b8dd65 |
|
MD5 | fe625d001e2b73ac8d3e7c21492d0865 |
|
BLAKE2b-256 | f521718427bf603cd63325027721bf6e2d0624a7f1c5d6b34185889d0409d48e |
Hashes for aiokafka-0.9.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e69a12956e3ff1a1d21c8e576bee042176551683310ddca27f25fead028ca46f |
|
MD5 | 862e08563edc751c93e14d899ad2a40c |
|
BLAKE2b-256 | 48075d64a12cde64affabc0e84d66b3ebd260a109ce70091f27a56c7556a564b |
Hashes for aiokafka-0.9.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a021c3ef27d8c045a15f8ec14bdeffa10a8959b491601304cc25c8081cf00af3 |
|
MD5 | 11abc863294e02869f8ba321f16f2e12 |
|
BLAKE2b-256 | 51e9efacf5caf6617eeef1861d0e807ba398bb8553380f569a20c44db8f00efd |
Hashes for aiokafka-0.9.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93918bc9a33019e13932df8cc461fee488b6efbb58093d4876890bf9bf8785f0 |
|
MD5 | 1a86b71f1c91725b3d22e472dec594c1 |
|
BLAKE2b-256 | 6288d361b78e3278259e148766e9d47293f943926b554d37dbd0d2004413ebfc |
Hashes for aiokafka-0.9.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 035383408b411c3c180b5dd8e5794ef0bdca50921b330f022ebe33cf977c1e9b |
|
MD5 | fcfe60cb4611f71294de1c77fdf3bebe |
|
BLAKE2b-256 | 3e0f4601ab6bc4c7e9ddf17b49086986862349d74a53857b3bdde06ede65a2e0 |
Hashes for aiokafka-0.9.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4feaf851fc68ebd90438e28509471cf10dc068b700cc446a21fd8c696eedc370 |
|
MD5 | 524fbb979cd54189b36533527a470eba |
|
BLAKE2b-256 | 0bb31a1f7a3b81cad617830b2d088b6c1f46f12c1e5bfc19f4f9ec59f140d86b |
Hashes for aiokafka-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 332828c7b12ac19133d4af60e3a86a7b6e09b28d6157e50545faa4ae32a2617b |
|
MD5 | 9450d686fc29837c4b9eba946bfd81a8 |
|
BLAKE2b-256 | 9d51f9361575a1ca311a751ef7242590d966a13166f89a73619d9341c4ae4d73 |
Hashes for aiokafka-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0b45b3f4b9448a3e2256615d1a93e1e2cae186a810b9bb928d224ae5ea04472 |
|
MD5 | 1d13a7fe499d86be041709c18eaf5a85 |
|
BLAKE2b-256 | 2132eee15e7f3bd2c7f121f6d4d6fe0e0ee8a33b1fbe8f7be35c587fc26a195b |
Hashes for aiokafka-0.9.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3cb09e16846d77094ed2940ef9a64f3956fae85aab9fd6f5e7d5c77b610d9ae |
|
MD5 | a44b3bb74e09daeb3b5be08b0069697b |
|
BLAKE2b-256 | 921ae692b2266c4b7703d905dc628621f2578f4169a0542092f8e9cfbf68d62f |
Hashes for aiokafka-0.9.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e63c80bb5753382fcc5137f62307f837678d00847b5386d0f3803270843d52e |
|
MD5 | 64e83d400525015887042109dca278f5 |
|
BLAKE2b-256 | e1d8ea825a77066195d9d4fa46a0085bd4820f261d553b9874a334b4aa25ef49 |
Hashes for aiokafka-0.9.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e67187a7a399ed110bb70a0fb5a74d5351589dfb7dab9fe88901b81794186990 |
|
MD5 | 61788ce55975726676a879c06fed2de6 |
|
BLAKE2b-256 | ca6395ed08feadd03468ea7d3d81231b2ac3d5ac3e537ef19f4f830ced8651ed |
Hashes for aiokafka-0.9.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f11e00ecc72fad86c51c594d0c9d336a99b478a127887823b7816cc00c7c9799 |
|
MD5 | e1d607ed37dd1957bcd5181ee1afedf7 |
|
BLAKE2b-256 | 9ac9f1b67f4cb79af850a719e20523f2ae536f52d2b48556c527b4aff2209447 |
Hashes for aiokafka-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f617e107bf070a9644c2eaba0388fdf1022d4c7a4f7bc387243de7c87afcece7 |
|
MD5 | 3cf8a834c59b962be5f9fb23b69b6ab6 |
|
BLAKE2b-256 | 71aa883877397328ea4f2520e5c310459d28511b051fd096e3f2e48faace26e8 |
Hashes for aiokafka-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a2a24faee32e7170ef07691d5af75bdd572e513dea162ee398c80ed1c4bcf5f |
|
MD5 | 730538b106a9907afe31a3774c0f2955 |
|
BLAKE2b-256 | 612772b66c1317ab78590fad105f92ffce6b2e9c06cb5887cab1d4921545a746 |
Hashes for aiokafka-0.9.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85b53b41e3ca536e303352deba65be8f9932d8908f87bb8a59e1a96e32d5892a |
|
MD5 | 4e8f93864c1c7ac6b785d92d8c6c7f57 |
|
BLAKE2b-256 | a753c9b92db4bdc7f2a5edb397a31877d12e6d0236f17dd1c5d93f3ec14ee413 |
Hashes for aiokafka-0.9.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc9ccae749f15a0a316d6dca7c1a259524854c1d111d0a981ec9a39416afbe4f |
|
MD5 | 9536b7c5748a4052ce561119a33a4d5b |
|
BLAKE2b-256 | f166a45e939d9c5af06fe5585c71fa35750a431d0d508b47a1348f1460425145 |
Hashes for aiokafka-0.9.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0db60cc9abd4399b25f49c79318a680d446297aebf5e51b25b351124b437d122 |
|
MD5 | d26fac179bf8e7ea947a0e09d4f68771 |
|
BLAKE2b-256 | 200bd4e6c695d780826065f6acc658f851476257821973f359b84861020251b8 |
Hashes for aiokafka-0.9.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b0c76944e09702d0cb9a26777aec3fd7ec94d18144531a34b7ec8a980a55747 |
|
MD5 | cb166cc591866640afeefa08819e7c05 |
|
BLAKE2b-256 | 06cecd9a8c76e6c34bc900bb13356b015299247e92ce52e4eff608b040ed3ca9 |
Hashes for aiokafka-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209458fffff5560bc59ea6032e678a1bf018c7fb3dbdd622c0af5b81e3e2b902 |
|
MD5 | 5628f7b45d77fd00ac16a976f0c989a3 |
|
BLAKE2b-256 | eb542e536ed99ed2a8b9591cc314768b37a31e4905d4ade3de1713a1dac32d54 |
Hashes for aiokafka-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32dfdb19a60b1c85582ae12f8466136ff68479ed5c9b874240e034f468384895 |
|
MD5 | 28ab185979d782121147b901891b9460 |
|
BLAKE2b-256 | 2a8a8b0182189c239e23956d9067422d449628b26ea68456ab0c6a9b38fd4f28 |
Hashes for aiokafka-0.9.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 320f2b504b0e16ac67e0d17d48bd08fa9ee3c3e1bafebe61b404aa16142a2129 |
|
MD5 | 456d0dff47fda829ab4699b177d935a7 |
|
BLAKE2b-256 | f9dcc97da0d1ee8f260009e0daba2bfe886cc2fb74faffb846ef52a8b112818a |
Hashes for aiokafka-0.9.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07d6e8f0e3a4ef555fbc81ba7bca63dfbd5620dd12255242eb12e6a45c47c9ca |
|
MD5 | 19caaf412f053f83766ed9793be3bf25 |
|
BLAKE2b-256 | 30863db1c25d692d2a8d31ac9fdc5bd98096ea6e78d006e76fe057f1a85f5d82 |
Hashes for aiokafka-0.9.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1131ae81f1026a64836d85f53b8c5081f771b85c4d00a9855a69245af71e1691 |
|
MD5 | 9c23a7fb8141c79ab6771b813165f6cb |
|
BLAKE2b-256 | 278a1bb91fed32ba79a6b357b4a3523a28b65d87b0301347b65edca08ce56f2e |
Hashes for aiokafka-0.9.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f1e2feded35e748976c9cf83b5148d9f00a749f6494da872f9a5b48601152d0 |
|
MD5 | 7e262b9c3bac63f7dca2e729395fd00a |
|
BLAKE2b-256 | 24c76edc4180cd901513a4b07b20c6095bf49af3133d81286d596e5c6cfdfab6 |
Hashes for aiokafka-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 766d965262225f79474558f528b01abb83cfb73832ab50de823b326e5929282f |
|
MD5 | fdd998057afad153f5445c8f135266a9 |
|
BLAKE2b-256 | 2fa2e34fe16e4907e66afc5463339a007e64d5477ec2e39de31c6640aaef6c16 |
Hashes for aiokafka-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f24c4a9eee7f0a201943aa41b7f922ae5821a5be2b38b8264fc171d9e09e64e1 |
|
MD5 | faab11509eeea6bec9ddd6bba6f2abf9 |
|
BLAKE2b-256 | c67c4b99dd03f6d27a8573046545ac5e42fe8fa57f388cfc0ce222c2dbb575aa |
Hashes for aiokafka-0.9.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd00d685b68d93ef50051f51196b508b767746d66cabbd3fa0a8cbfb3ad5d0a4 |
|
MD5 | 00a2f62a8f97d8f6204db8a5af1486cd |
|
BLAKE2b-256 | 03d76f7f8fd28c5bea110627426129eaccc4a8a4429e2c26ad0979a271e6c170 |
Hashes for aiokafka-0.9.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47b701d077e1a3b2b6f254baa947b0b8faf47c68514bc19297227917d0e227f7 |
|
MD5 | 3f0e8c36601fb218c1eb28cec273f534 |
|
BLAKE2b-256 | e9a047b5ba33d43328fe144c2fdd890a4826b1f91f7af00e22e1f1af53ef39f3 |