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.0rc1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1358c724b35f2b856429f2cdb7593e42f2fbcdcbdbc8ec2888ccd68c4bef279e |
|
MD5 | cde0c96dc681941ad58b275e1b95505c |
|
BLAKE2b-256 | 8fd16724f250cf91671bfa1a3bc7b6d8dd86a5c3dfcbbedb5683276cb3123d12 |
Hashes for aiokafka-0.9.0rc1-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8ca99b03cbdc58aaab292f26d95ad5129f7c1e412d085bac138ca59901a8ee4 |
|
MD5 | 44c7f5e40421163f6f18eed7b7223057 |
|
BLAKE2b-256 | 39a3b7c73b537f146ea99f19a5f480b323034fc3514b969bbbdef10c97e2a455 |
Hashes for aiokafka-0.9.0rc1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 930b62ce28872b3a5778317aa79e271fecee277921d847b61898ef347e830a19 |
|
MD5 | b5ee415b73fb3060df6b6c93ea6b7955 |
|
BLAKE2b-256 | b3d873c9334c5c0d68d1dac65f06645d3b92dc5edec23d7bfd45712397770081 |
Hashes for aiokafka-0.9.0rc1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d30ceb5dfe349ebea634d4022a027a99ed3d384379931a0de1c8f83e16368f11 |
|
MD5 | 309070aad201463623890f98a332852b |
|
BLAKE2b-256 | 443b8e511ec884889f9f068ea3fcc843874bcfcf84f3fbaefcd65d312c5a69ea |
Hashes for aiokafka-0.9.0rc1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3a62a605824fcab67ecfb128e1482d829d911e487ef3a2e5ec19154f6108112 |
|
MD5 | 5cd631fd681325cd6cee5d738a21e6bc |
|
BLAKE2b-256 | 12e678d4cae747992a5bcb7fcf2c5a642ea5bddd8512a3014eb8fb2a7b6c8335 |
Hashes for aiokafka-0.9.0rc1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95746c84cf29279fc08f518c5aad76c23398d45718f22777f1f7519c99b8e28c |
|
MD5 | aa152623ce49683a7c582fd7301cf867 |
|
BLAKE2b-256 | eef4d51cee240b333282d4b30482ffefe9b97bc2139ea89c2c8a6014fa440324 |
Hashes for aiokafka-0.9.0rc1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63150f3914084893f1edee1664a5ab06d6c847a771a4713ae1d86e8b462d7cee |
|
MD5 | c41635f6d9f82b319d0148ce96fd31f8 |
|
BLAKE2b-256 | 005a3eafae53282be32555d328598c2cb38422767cafa73a907348101279b794 |
Hashes for aiokafka-0.9.0rc1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeb71f2e02a6b4d2143499505f770ba4c9a3f65c3274eb83c8886a30004ef7b6 |
|
MD5 | 21b590e4a9692a75b73b2be86d5d2808 |
|
BLAKE2b-256 | 76c1e4ac7700fa0d46f248aa68395197c34a5d48a7980d4836e04bf4bd761193 |
Hashes for aiokafka-0.9.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78af97e0704785144eccb023e6d0e229e1c47d2dc5c7e7b3a2dd49d67c8bb52b |
|
MD5 | d6cf92c801b2838c5a33c824a4ed5696 |
|
BLAKE2b-256 | c172be99577778b8107854dc675012e09e050f26dbbe3fbfacff2f7b2a4b3fb8 |
Hashes for aiokafka-0.9.0rc1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 451bf9d1336ae2b9df0d24c78536d760313b55bcafe965dbb7925cb11a9a92fc |
|
MD5 | e5279f9a756a4346489df104e889bf73 |
|
BLAKE2b-256 | 14616c46b3f8261fbf9ee3c5c433729834f6dc18905af7ec3e5a0c989bcc6d50 |
Hashes for aiokafka-0.9.0rc1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8dac48ec6bfe8cae595ebf1fcb2329af506ed7bf37b07751d0df28d53343a03 |
|
MD5 | 5d498a49468196f69fbbd60103f455ae |
|
BLAKE2b-256 | 604ccf367b8b827d3cfbd191a4876275fe29726b8d1c2a21abe7dad3e9f4c5dc |
Hashes for aiokafka-0.9.0rc1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e31a4b4a4900f10f29c69e6778b32aba7a28f7a7ffd9aae8dde9fde74798af0 |
|
MD5 | d51bc2b035e3a4d7278c19273edbb7d3 |
|
BLAKE2b-256 | b3255f1bf968968431d54d034ffaae2d9e42053c3ce8830ad2fef5752fce61c4 |
Hashes for aiokafka-0.9.0rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eded84dad4608a9ccf42dc617db824cd463ff14587dba7fff258fe71383b6f31 |
|
MD5 | 31adcd00dd2ecac00b7fa598dc858b0b |
|
BLAKE2b-256 | 7d00ff184402834c3f7553e7d3dcdd429409caa851ebb7b5aa0965fb8d11eef5 |
Hashes for aiokafka-0.9.0rc1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7f7ebdf3970e0be3ae31bd7f3a8ff8d545e92c44c8eeaac4f1b65780e0eb1b1 |
|
MD5 | ce6d9fa04da47bed480920ac10a15e44 |
|
BLAKE2b-256 | aabefa5670e4107884015b427ec6e10d49b428a76004959a6299fcddfb511445 |
Hashes for aiokafka-0.9.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 648cc5c3177973ee8b922a5a6a91cc32bfc3a4a6d1027e0b0bc1831c75c65b8e |
|
MD5 | 405a3456e0572269eac3045e3d1efa45 |
|
BLAKE2b-256 | 2e3263f87b8b4d42dcd3888d394b29dcc29e45797f49d0add7d227c65012e9a1 |
Hashes for aiokafka-0.9.0rc1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b78757c0ee6dc1dd61ffca9fc8428a03d4a287972663fb63edbedbc5300d1744 |
|
MD5 | 452ed7e5bda6ae3f66d67b9a5a8e0981 |
|
BLAKE2b-256 | 9d9489e43293e1fce7533136c62393c8475649e57b162635448653442d6f1789 |
Hashes for aiokafka-0.9.0rc1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fe93b31925a90ecf2b98c4813925b1cd72957bf0457fe5f6b591b006216b42b |
|
MD5 | 183fafea8e949288ac23f7ff07e381d3 |
|
BLAKE2b-256 | 9164530bf3e1e5b5afcc61b90ffd58071be6ef8ac6386cc6fd78730a099d89ec |
Hashes for aiokafka-0.9.0rc1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0030bf7ad027fec48c8398cc9577484f3bd507aa14295564d0d8207e5d58b611 |
|
MD5 | f042e7b1363564db6da5b8c793c70bb0 |
|
BLAKE2b-256 | cee70a69388c6e1d90ab7938c3f69d3a96b9af58d5f8f7365640e1cabab2e6ab |
Hashes for aiokafka-0.9.0rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 627b353d700f43a008ded44c0a33432ec6712825c85352ab832bf1043994e7ee |
|
MD5 | 640041b78abbc42be0c9e8395341a4d5 |
|
BLAKE2b-256 | 2a15a19d23daf3359929bfb22ac93ef1902ee23671546e28b237beb27fdad57c |
Hashes for aiokafka-0.9.0rc1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 947b5f957e3491a9f255c81f44ce8d0a0f27febf7547fb11bedb6101b5d7bbc8 |
|
MD5 | a04436dc0774026f8811f93a8440a6e8 |
|
BLAKE2b-256 | 20c49ee688d5599a8e32efacc8a7e6bcb97af3f1a54d76a9ebc1b6863fc2c444 |
Hashes for aiokafka-0.9.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f97f1e81e01bb762e995f1f84820c8763d385e7fc98b25cc5bd5088c9f25799 |
|
MD5 | edcbe0f9a39646b940ea22c55837b5db |
|
BLAKE2b-256 | 0fd7b6008f74603b8762cbcea0b33e46a112983b41006e80783264f4840f6558 |
Hashes for aiokafka-0.9.0rc1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e845e0107799db9c672c1bf9b0bed5ad27c28d2445d8bf689829c566a0535ae0 |
|
MD5 | 45bd6d6a16c5a13f5f81bb2ceb738e07 |
|
BLAKE2b-256 | b4343ca346aa79dac40b8e63146de8298bed7b6f9788e1d6c7181181f7710ccc |
Hashes for aiokafka-0.9.0rc1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce307767f09dbfd8495e2055fc15b02723c5785aa40257b45ecc463178ffdf18 |
|
MD5 | 23d467e986fa143f8d9d3aeb15b6e1eb |
|
BLAKE2b-256 | 88bc12ec872745fc9d89c4ad30d418f713d60aa8b4381db0b7ba0416c555c77e |
Hashes for aiokafka-0.9.0rc1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5e75c5a1a786a6c9887b1f7d05cb1df0e3bc482d3d8f97085daa8eb39a6289 |
|
MD5 | 115b8c058106544ad0b9513dcb878576 |
|
BLAKE2b-256 | 7b0c814ac722f14ac4041b241f2a49f0f49c22e3ab7fe2b86ad43dcc7389df23 |
Hashes for aiokafka-0.9.0rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5806ffa3128ffa57320bf520d29c72fd0ccffb29404101a8daf5134be21ddb71 |
|
MD5 | c929e9a4398bc242f8d896b9b54ffb78 |
|
BLAKE2b-256 | a9916ac2df2ec5f627cca457f7de72cfe67b1cc29b90f31f8c626048a75a7cac |
Hashes for aiokafka-0.9.0rc1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3745e24356788e0785985d566d969c1ea08048cdf97a8fcc29a590058af824f3 |
|
MD5 | ae0d46d7080b5fa46d440c1bcfe081c3 |
|
BLAKE2b-256 | e5b77083b83e719481460b96cbc72029695773c5e93934b280c0a9c3d6e0d2d8 |
Hashes for aiokafka-0.9.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb740f7556877254f36c7441f1badd1ee8b864453c454c73e5dc6ccfaf9a143f |
|
MD5 | 40cacad2c4951ec283a9dc4ce5400a95 |
|
BLAKE2b-256 | e564f0a226622c4225e4171eefdc8883655531b2987cca3d1ac5201914ef0044 |
Hashes for aiokafka-0.9.0rc1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cc0eca8a0a72c9582b627e674d3a8b132a8f0ea01a3dce0e11d8cbe08d04750 |
|
MD5 | 83e3a38208224eca6e328440c2262d62 |
|
BLAKE2b-256 | 5da51bcab57cc925f1c05a50af894a5d16b129b0329876ff7bd8066c7e920dc3 |
Hashes for aiokafka-0.9.0rc1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92e633d88850a1f530e867afa74a061db2bf5762537259036029ed3aea742e56 |
|
MD5 | 62a6a04e836f7fa7100be2ea6a3ad59f |
|
BLAKE2b-256 | 82320d60ba1a94c73266284695576a81706d34310f11ab7193e1da7b18406fcf |
Hashes for aiokafka-0.9.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a1716aaf4d753132fd75f4fbea5b38d609db169d052d3e202194b80c8243b5 |
|
MD5 | 17825e57f497243e129878b3739844fd |
|
BLAKE2b-256 | e5b8f0298d68534e195062db599f88146e2f00bc9bb04d57c620e9a0af704170 |