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.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4b22a31f40493cea50dddb4dfc92750dfb273635ccb094a16fde9678eb38958 |
|
MD5 | 2fbd60b9a9655a68474214e25cfa1c7a |
|
BLAKE2b-256 | 49e839fcac87254bebfa679e0d8b53b83633e8c32adc6d86821e6698bea6b4dc |
Hashes for aiokafka-0.10.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de56c503b3d64e24a5b6705e55bc524a8357b0495402f859f921a71d65274cb1 |
|
MD5 | 79a8616bdf1ae9168e27ff36b39ba766 |
|
BLAKE2b-256 | 200ff346e22b4ee145c8d0352c2abeb936f59f2969360e58e7e56e30ea87592f |
Hashes for aiokafka-0.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12d703317812262feac6577ff488f2ccddc4408da0ff608a5454062782b5a80d |
|
MD5 | 7405c124eb73deb481f057a40ca2fbf5 |
|
BLAKE2b-256 | aa43a25ea0689483ef5436b3217fc7a4816a8ef604654bbf492bfa1bc49ea568 |
Hashes for aiokafka-0.10.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf9e241766b7f4c305807763330dacf8c220ad9e8fc7f2b22730a2db66fad61d |
|
MD5 | f2e3cd5226998340fdd8c71229380c7c |
|
BLAKE2b-256 | cf6b70dd6f8521b1edca42672fe8d0b5a48abfba545c5c8ac0cf89979d0f8825 |
Hashes for aiokafka-0.10.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b74aeacfb8ced9764002c63b58e4c78c94809131d89000cb936c25c298ffb1e |
|
MD5 | 2ad12709e24ab92eb01c2fbe0e2cd6c4 |
|
BLAKE2b-256 | 5cc7d5759d58909c88ad6c897e45a2e3f5edbb98a580eb78a56aeafac03bd040 |
Hashes for aiokafka-0.10.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82a75ea13d7e6e11c7ee2fb9419e9ea3541744648c69ab27b56fb6bca5b319c1 |
|
MD5 | ab387d28c39ad95cc1029d39831a4ffb |
|
BLAKE2b-256 | a2b2e44f06e882cd03f3ed07a72a289cedb30a9ba4d23c2dfea3483db4d11911 |
Hashes for aiokafka-0.10.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e10fdee4189fe7eed36d602df822e9ff4f19535c0a514cf015f78308d206c1a |
|
MD5 | 66cbc0cae807611ca81e54625235a5ab |
|
BLAKE2b-256 | 62c5eb688c087ad7e2afef6f0badadc2b9120126c40c4513dd78de8548d4bf41 |
Hashes for aiokafka-0.10.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffc30e4c6bfcb00356a002f623c93a51d8336ca67687ea069dd11822da07379c |
|
MD5 | 62e50c24eb5d8170504d4e519eb04c5c |
|
BLAKE2b-256 | 8028da51c878eb5a682999bea09ab941f4507b975654547010c4aafb96a8c72b |
Hashes for aiokafka-0.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52c25f3d0db7dd340a5d08108da302db1ba64c2190970dbdb768b79629d6add |
|
MD5 | 5ec4cc7935360291d9153a55d3aafcbd |
|
BLAKE2b-256 | 405acd8857dbcd74fbe1da1777a5b2d37bd34aa1ad456ccba655057f7b8f5950 |
Hashes for aiokafka-0.10.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b91109dc25f79be4d27454cc766239a5368d18b26682d4b5c6b913ca92691220 |
|
MD5 | 2cf14dc9f6f43789c84208bc607a9cf0 |
|
BLAKE2b-256 | a88680f205be13bc85871a7007ad2e64bc78af98d99c9eb0ac2cc45aa11f03ba |
Hashes for aiokafka-0.10.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1509c1b29cd1d4d920a649f257d72109bbc3d61431135505b8e0d8d488796ff2 |
|
MD5 | 0e019a61d089b9a70fbe25052f6fa92c |
|
BLAKE2b-256 | 7ca591e36f4d8ad813665246146ec8f99276fecdf7dbfcd45b5d2660060e083b |
Hashes for aiokafka-0.10.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5efb63686562809f0f9bf0fa6d1e52f222af2d8f8441f8c412b156f15c98da43 |
|
MD5 | 6c861b4b6bed8d51e41f2940ffe284b5 |
|
BLAKE2b-256 | cec96d8212b74b1d0a022f83382c1ccf9c592ec26c72d085d88c1d7fd0e508e3 |
Hashes for aiokafka-0.10.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99127ab680f9b08b0213d00b7d1e0480c6d08601f52ad42e829350f9599db301 |
|
MD5 | d5cafc27d07a37e653eefde14ce1ef17 |
|
BLAKE2b-256 | 924df27a9b66db2116c1397cbf303006d0a2a2c3c06344ad2ccded6fb14d857e |
Hashes for aiokafka-0.10.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2f19dee69c69389f5911e6b23c361c5285366d237f782eaae118d12acc42d7f |
|
MD5 | b064a3ee639494e1b13ad9be4ce9512b |
|
BLAKE2b-256 | 456fab972355de193e04f83f831e37b3dcd48c9bf062c183eb86d40eb7c2240d |
Hashes for aiokafka-0.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22299f8d5269dcb00b1b53fdee44dbe729091d4038e1bb63d0bb2f5cdf9af47a |
|
MD5 | 82973875d8df224e8b7395be8c3450f5 |
|
BLAKE2b-256 | 327ccba05b5606a4acd72344735a7527c34dc8b956b48e115797a5ea8da77b25 |
Hashes for aiokafka-0.10.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 007f1c51f440cc07155d2491f4deea6536492324153296aa73736a74cd833d3e |
|
MD5 | e6070d02fe6073133228aeae60516c26 |
|
BLAKE2b-256 | 81c9188b13d3e631da6871ab8c4d5e7419789d6cd3cb3f39966212f10a8712d3 |
Hashes for aiokafka-0.10.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fafc95bdaed9e1810fcd80b02ac117e51c72681ffe50353e5d61e2170609e1fc |
|
MD5 | 167595c172f03e1e00599ac8f41b74cf |
|
BLAKE2b-256 | d5979f7371611c7b5e93cd5b73c1b00e880cbba32f1e835507e878c66a2e43ad |
Hashes for aiokafka-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebe5be9f578e89e6db961121070f7c35662924abee00ba4ccf64557e2cdd7edf |
|
MD5 | 07d6c34372788dfb80a59d88a27d09e2 |
|
BLAKE2b-256 | aefcf91474f09a52e4ec014d212ac66cfc00032d6fbb7efac06a98d2ecc297f4 |
Hashes for aiokafka-0.10.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fe0194ea72524df37369a8cf0837263b55194ac20616e612f0ab7bfb568b76b |
|
MD5 | 2841494efb071dbee3f1b6811c065227 |
|
BLAKE2b-256 | a75371a2057a19c5b9d450ac46d9349b53fc245a575fa2e3f6bb13ce8cd05fae |
Hashes for aiokafka-0.10.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05c4a7ced5d6f3dbc289767574d6a5d9b31e1c243e992dcecd34dbc40fcbbf9b |
|
MD5 | 518ef60ec20329bbebf1e7c6c278aee2 |
|
BLAKE2b-256 | 9041c9790a8713ff91888d1638a8fce7fd801cc56f6bf1d233bed325558ea2c9 |
Hashes for aiokafka-0.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e833e4ef7fc5f3f637ba5fb4210acc7e5ea916bb7107e4b619b1b1a3e361bc62 |
|
MD5 | 0ccd40e56f985a64ec5e46bd79bb5903 |
|
BLAKE2b-256 | 29bd5fe749599e5177736b27a0bca68bb979aa5eee3c29d2354ac8090fd7146c |
Hashes for aiokafka-0.10.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74229a57c95e2efccec95d9b42554dc168c97a263f013e3e983202bd33ca189d |
|
MD5 | 41595903dc35fa3ff4ebe4bce9a28a20 |
|
BLAKE2b-256 | 19a30bb6dfedbcd867d13797690c10855d6a4cb45400ebc051ea86cf60490f9e |
Hashes for aiokafka-0.10.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9728c523f10ac4bb46719cc64f3c1d47625898872bc3901b22b9d48b6e401d1c |
|
MD5 | dd6c63b0f90ab850aa8d952f5466d095 |
|
BLAKE2b-256 | 036550a0ddb4d355811e887d7d064074628f3919691059bae19354b1df64646d |
Hashes for aiokafka-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c23ec22fbf26e2f84678f0589076bea1ff26ae6dfd3c601e6de10ad00d605261 |
|
MD5 | aa2f404de79277060e3e3acd1a9302fc |
|
BLAKE2b-256 | 2ed7ca05fc2c54985b5ff72f6b08a520cb371c1a402e2ebb652d80a2648a8945 |
Hashes for aiokafka-0.10.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06060708a4bcf062be496c8641fca382c88782d3c381a34ccb5ac8677bdac695 |
|
MD5 | 12bde7a401f450e802b919baca6d35b6 |
|
BLAKE2b-256 | 307b27edfcf95bfe37086d871e9e8e6d72e4c1d39b448d62bb7d6c390e09b4ea |
Hashes for aiokafka-0.10.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 781ab300214681e40667185a402abf6b31b4c4b8f1cdabbdc3549d8cf383b34d |
|
MD5 | fe9d56031a56daa7738ea5456d6656b2 |
|
BLAKE2b-256 | c8db881ca13449c3372916520927749f462332877f633d3db9fbf54d3dddb8fb |
Hashes for aiokafka-0.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e16d8a23f0e173e5ca86c2d1c270e25a529a0eed973c77d7e8a0dfc868699aa4 |
|
MD5 | 56fbde1de3bbef6a51e0a5d0653d5bee |
|
BLAKE2b-256 | ba40d41b3000204c56627fcd95b12e333409e2abd383ecf53a951e809e3584e9 |
Hashes for aiokafka-0.10.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f069bda1f31e466d815b631a07bc6fad5190b29dfff5f117bcbf1948cd7a38aa |
|
MD5 | 065bc16305848f419ba0921ee57f193b |
|
BLAKE2b-256 | 7d8e441a8b28cfecc11051ec1ee0ca68934327ae8025e294f0e64507eed3707f |
Hashes for aiokafka-0.10.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf4a47659517000a8fe88e0fb353898b718ee214e21f62a2a949be9bf801cd9e |
|
MD5 | 6f0aba8560b1d009e26974ef492a1498 |
|
BLAKE2b-256 | 6af8b8ad2cd2687e3edcefa131468da4c03c16e3f903ac7112b1eaff7cb5f130 |
Hashes for aiokafka-0.10.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7068f0beb8478cde09618dcc9a833cc18ff37bd14864fa8b60ad4e4c3dad6489 |
|
MD5 | fb12b528e79fa0bb796308b665059849 |
|
BLAKE2b-256 | aedf481b2e45485c812812953f56089bb45c1a6cadb158c940c3173c5a1a6416 |