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.0rc0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fcd3bbed69a295adf3ddc42b3c71faea15573f50b4ec76c3ba3be1a22585e35 |
|
MD5 | 234ca4cf1955794aa13d8a50cdec1cdf |
|
BLAKE2b-256 | 5253611b225afc997a58537be29478b5737e9d632d0e844c3b733edb5b7a7998 |
Hashes for aiokafka-0.9.0rc0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7273eeea2e75dbb0fbb4eb1925f5fb969dffb1f17acc4a5ead377cbe74052a00 |
|
MD5 | 147829b17d896bfdb7dd2fdc4c5d944b |
|
BLAKE2b-256 | ef0a16b43852a2ad9bcf5e6b0a1d138c517241e06abc78f2e830912391e38d8b |
Hashes for aiokafka-0.9.0rc0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25f1a1a09f6377eec1b3eee2630f3cc848620bdaa8fe33cd400ba68c00f7b9ff |
|
MD5 | 1214428f8df3946e019c48f5b17d9d9f |
|
BLAKE2b-256 | 23a77f9941be88bfe75138b0c027eaed5f3fb0e553bba42da9e7a13669e32c60 |
Hashes for aiokafka-0.9.0rc0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d78129f4c12117bd010f373f6a77ed5c515e57e86cda0b90001778355424cb5c |
|
MD5 | 3fb0bf3addd3ad3af9c26b937342c384 |
|
BLAKE2b-256 | dc8ea3255c23b78a90ea754a3ea4568555cfb6450fe30fbbf98ec98969c798b7 |
Hashes for aiokafka-0.9.0rc0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21d5b09d6706746d1dd96c6287b589a39a2b504707433ebcb71dd85dbdebbee7 |
|
MD5 | cad009b497541ba59e4841d54c4dbeb7 |
|
BLAKE2b-256 | a30ad1c55ee61c5dd29e96255f6fde2173fd434bb821368408b5c28a63e31477 |
Hashes for aiokafka-0.9.0rc0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbe61a2ff5d42ef8675671f446154e8f57723f9ece24bec16447c816c3af30dc |
|
MD5 | bcb04908d71c21529a8043924853d445 |
|
BLAKE2b-256 | 1c532b0bdf41b05e2982d255374c68f57121e5bfb607ca599c02fec4be7bc753 |
Hashes for aiokafka-0.9.0rc0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66bdbb1def60cf7af843c8e4248ee8f0db3e754488a4e7c6be667c4abecf618b |
|
MD5 | dac0559863eb9186009933153f7921ac |
|
BLAKE2b-256 | 87123f743da52b3e37ac529388add2e50cc0fcfc9747a474b2dfe425cd40de23 |
Hashes for aiokafka-0.9.0rc0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbf84323352542c6047772e7def4f62d39a38f0f6a2ab5ebfc3dc432a71f2fe8 |
|
MD5 | 225875619a63e270021e310be064dc8f |
|
BLAKE2b-256 | 137c3a20e72e7f2b13f864177cdfe47e85c7cfd0c3384ecef1e7056297085f45 |
Hashes for aiokafka-0.9.0rc0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fb0a7db5d1480e204b6fa5a4b00746e65620615ee17654e59da36a5d3789c71 |
|
MD5 | 62fecc2bdddc7040103cb31cf7514e0f |
|
BLAKE2b-256 | 4d000ee4d1be26fd8f33692c0bc1800d5d8f9ff2b893d57e48742e764e2ea7aa |
Hashes for aiokafka-0.9.0rc0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 845593532ad83046b50bd18124f6c40d681c3fb5c455b65f3c9cdeef41e215a2 |
|
MD5 | 9aedd6284014cc3d711b771406fa34be |
|
BLAKE2b-256 | 082dc1d84fa928faa7f7f6940df129de37b32a3c26227a4244429ce55ef9f2c6 |
Hashes for aiokafka-0.9.0rc0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7c7f20e3477d96d9f0f9d26a6d19d2a26ec74d2aefed5c8af17517bfea1749f |
|
MD5 | df21cce4e3a686d45a5078cda08888c9 |
|
BLAKE2b-256 | 00381b0fee1c8b94308fb25b4d1d95141a9849855b1e4edf2a8e4f8bef555506 |
Hashes for aiokafka-0.9.0rc0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08d77bcdf99bae75c1949a30bbb1adb8ba8d50d4b76840db66fb6396bf7509e1 |
|
MD5 | 990b9a3eb9c679d74d966663b3c587a5 |
|
BLAKE2b-256 | fc701dbb68b79c91544afc5ccba3298d1065ab6c37a6820bf575b01f822aebae |
Hashes for aiokafka-0.9.0rc0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0c9e02e2b8516254fe23b576481148f1196bb8eb072bfdad78fe62180079188 |
|
MD5 | 1537abae42c64793e1f4c3b839b9b6a6 |
|
BLAKE2b-256 | df71b144185b718cddca8ae9251f2220115c55c3dd25ea83766b29caf3c54b64 |
Hashes for aiokafka-0.9.0rc0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 620f2e6e9deb28c090fdfc18b2ebe8f913fc44f2242ad87c4675c18405d710af |
|
MD5 | b2cf38dff20a89377c18066ccab00269 |
|
BLAKE2b-256 | 3745afddd82ef63f84bba85010bc1e9936874c09740ba1d0506b9686ad7eb2bf |
Hashes for aiokafka-0.9.0rc0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21ba182ca0a17df6c70667ccc4d78aaae44cf18adbf999cb14700dc2713a19aa |
|
MD5 | d030ce75fbc7f32bf759854c23181745 |
|
BLAKE2b-256 | 9b6b2b5e2f58554b8c2057fb4c3cf17ec959be56ac4faeaeac1d29f8dee66502 |
Hashes for aiokafka-0.9.0rc0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9658f1a83660943fffa68bc33fdb7150e8a09e5547c2f76b359baed1f235a02 |
|
MD5 | d61f83adab6f90a75963e2853768f371 |
|
BLAKE2b-256 | 2c592e2f95ffc7b5717b1f27a174a407cd0b11df4c7e2341dcbff85a577aafbd |
Hashes for aiokafka-0.9.0rc0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a44cd2a10b80fc4a3edd591090a80a30b365539ed70d948a443b6be5756731c |
|
MD5 | ebede4973cef28cf52b01811a4902607 |
|
BLAKE2b-256 | eee7ec68888ffa32cabc8a5b0e414f4e452b5739dd106cc031da4b04cdbd9957 |
Hashes for aiokafka-0.9.0rc0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee97754c49947e45c7014678829324a9197c9cfe079541de4b3f43ccb5e1f7f3 |
|
MD5 | f1ffe882474054a0a511060f0a982bf3 |
|
BLAKE2b-256 | 589d1438fb74c1b07ffaf52c5e4bbf5b2b0541ab7810dc93c1193044bf6560fb |
Hashes for aiokafka-0.9.0rc0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f90e3867581930eed4378520090bd4c77e8fefaeefbc83f0591f5ce3966b9178 |
|
MD5 | a86a2d525da8c2f62c17144cece05883 |
|
BLAKE2b-256 | 2aa82afd183102fe403fddf88d5739ed924269512f26959c11b07856dfa1bc6e |
Hashes for aiokafka-0.9.0rc0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3b111b6fac225385b161d8ea049ad2e5e7a20284dd652ee506455bbbc9fd7db |
|
MD5 | d135fc281da909951a28b517ae4cb8c2 |
|
BLAKE2b-256 | 99eaa49ebb9df857844a85514bd4848fd6e89859d90031fe011d91e0d8176784 |
Hashes for aiokafka-0.9.0rc0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea252aef75f1811d4379c97e506e7b7df8c06d43790172a1e8a0870b115f5938 |
|
MD5 | 546af2b949271e62421c74ebc2723486 |
|
BLAKE2b-256 | 579f4b921b907856d3ca9362e6a79856b7c2e0bb06700c8811c8628718ed193a |
Hashes for aiokafka-0.9.0rc0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dda2ea871bcafa45e411d5d0fb369dd8d84e37706498c31f84bace0be35ac55 |
|
MD5 | 967f74fee805f559ab28c14fd19d735f |
|
BLAKE2b-256 | 687657f316acc45d5885ef8d81de2008774a4d5cb33018ca032b5fc75f6b6404 |
Hashes for aiokafka-0.9.0rc0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a546d17b115bd6857633bc365d58931fafa079c41200f59fdd5b5dea3cf2850d |
|
MD5 | 9fbcb386861968ff9e7fe0e4be7b4cf6 |
|
BLAKE2b-256 | 97fd9899d81b997c522c061d13596b51a36b49cd457c4c1d1c64e8feaaf5f69c |
Hashes for aiokafka-0.9.0rc0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbf528f58bb546fb87c45d7b3065e52c2f94c87bff514ac41aad0d487655b8a1 |
|
MD5 | 7824b1d3a6b119fed4727f7b4cff8d7f |
|
BLAKE2b-256 | c05afd080c1f09369f15eeb5af048a789eb5446b3c8a1089a453295f823924cd |
Hashes for aiokafka-0.9.0rc0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b016bf3760827eb64a445a3f6a030bf87c6c36a821a6c935956721eab425e8f |
|
MD5 | ae68dbab135bdb265062c95af6c41785 |
|
BLAKE2b-256 | 21aae7ca91f49423a30f49e9d6a9333f5f602c6f7bdf4c945b258d615b1bc6ee |
Hashes for aiokafka-0.9.0rc0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac94301f71ba12d6160e72fb2324670336e758a2d1e5a3d27bd0492f2f46bedc |
|
MD5 | cd1aad25a918e8ba23587f1f575d1edc |
|
BLAKE2b-256 | 80c7b4d089452f7331ab62be824dec43358e69c26b8c80effe82b0b4f40bc48d |
Hashes for aiokafka-0.9.0rc0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c050aeeb31c34a7eca4cabebfa2cd9d53f9270f0711604fa9c6ceaff8a9bc74 |
|
MD5 | 0e76294d435430e061bbaa9b0886b89a |
|
BLAKE2b-256 | b1ed78ab0828c6c241ced658c42491c354e6b8bb5861423d3f203bfbdac4161e |
Hashes for aiokafka-0.9.0rc0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0610ca74f2c4071e8ee78dc445d3a0935d03efa4ec16ecd57b42def1fdd5a318 |
|
MD5 | d655a09158a91ce6fe6e164bb6bf7a1d |
|
BLAKE2b-256 | 324b833a7e30190bb19e08e130be2ddd46e838c504f852a935e51ee314f8fd65 |
Hashes for aiokafka-0.9.0rc0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd00db91a6ab045abba91a5642d3d433ea5f756c6766ad1299fe32c1390fb6a6 |
|
MD5 | fc162293c35a5ff93410f9e0fbf2656c |
|
BLAKE2b-256 | ab12715fc7d88d52f0c179cb18061fc6599f570f4b1dea64fae23d0c12eeaa27 |
Hashes for aiokafka-0.9.0rc0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 305fe0676f696af19551bcc1a3d0288a8a5531c457ba0f967a055493953e16fd |
|
MD5 | 85a9b345d9ec39ca20c9e934791a1231 |
|
BLAKE2b-256 | 2a595a964790962f797e467bf28789d64c6fd51e65e925eba839f17837553dab |