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 libkrb5-dev krb5-user make setup
Running tests with coverage:
make cov
To run tests with a specific version of Kafka (default one is 2.8.1) use KAFKA_VERSION variable:
make cov SCALA_VERSION=2.11 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.11.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a478a14fd23fd1ffe9c7a21238d818b5f5e0626f7f06146b687f3699298391b |
|
MD5 | 4c2ab862ebc519b5412c7dc7f80959ed |
|
BLAKE2b-256 | 5594f532c5789cdef414bb185ac9a62c30a817fd6eae5364339a90d317166bca |
Hashes for aiokafka-0.11.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ba981956243767b37c929845c398fda2a2e35a4034d218badbe2b62e6f98f96 |
|
MD5 | b808c494160477266001c05318c6d913 |
|
BLAKE2b-256 | 550081c805688d5aa286be1ab57ed30fe665ebec74ad2305fa9aa2b29018e140 |
Hashes for aiokafka-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3711fa64ee8640dcd4cb640f1030f9439d02e85acd57010d09053017092d8cc2 |
|
MD5 | 6607d9d42cdd8f666a863a5a13d28f6a |
|
BLAKE2b-256 | f4a9746f0c73f65f6d339d87873d6475ebff77ed52a50ecefa5b21917da1bd1c |
Hashes for aiokafka-0.11.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a07a39d82c595223a17015ea738d152544cee979d3d6d822707a082465621c |
|
MD5 | 45f1708936ddb4884a8e68dd74c719cc |
|
BLAKE2b-256 | 17b09498ac74ccd9286e9a750dcd6bf1601bf7d9d8f4b397dc830be0ba49c727 |
Hashes for aiokafka-0.11.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 818a6f8e44b02113b9e795bee6029c8a4e525ab38f29d7adb0201f3fec74c808 |
|
MD5 | 62a2c9439dfaac8d8108f79a7c4cfa8f |
|
BLAKE2b-256 | 6fe8105a1ef62b091b1fa7d5f236668140c776736dc87da66d8bc1aa26d4f84d |
Hashes for aiokafka-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e0cc080a7f4c659ee4e1baa1c32adedcccb105a52156d4909f357d76fac0dc1 |
|
MD5 | ee0b4954d897182b0d1104dc4460c189 |
|
BLAKE2b-256 | 9e6e8960d924b66931344b85a6043c189094738d3a8b38f649c01af9fe2e5398 |
Hashes for aiokafka-0.11.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f8ae91f0373830e4664376157fe61b611ca7e573d8a559b151aef5bf53df46c |
|
MD5 | ed7897f9dc77125681d40a68eec7cd9f |
|
BLAKE2b-256 | e066f119e1d8383a172568f3c8e46b5f505038d03a300c85051f1a82f7f195ec |
Hashes for aiokafka-0.11.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 560839ae6bc13e71025d71e94df36980f5c6e36a64916439e598b6457267a37f |
|
MD5 | 1dd8397d9bdb20bd20ed76a440c0b95c |
|
BLAKE2b-256 | 210134e3bce1073a5e7c596500816dff6e90be92fbda10390492b792c8d73bb2 |
Hashes for aiokafka-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ef3e7c8a923e502caa4d24041f2be778fd7f9ee4587bf0bcb4f74cac05122fa |
|
MD5 | 2595033fb8649ce66f941918708806de |
|
BLAKE2b-256 | 5c25a987c2a132deb742b21815a51bec5e244135ac59cefef16accbe861963c4 |
Hashes for aiokafka-0.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 224db2447f6c1024198d8342e7099198f90401e2fa29c0762afbc51eadf5c490 |
|
MD5 | c0a1b678dfae5f1db2d2690c2192d3de |
|
BLAKE2b-256 | b7cd349fd91c2d30b79d2cd9c7f7aa565069e1e59b8431da20dd07e35a0a5908 |
Hashes for aiokafka-0.11.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f4b935589ebb244620afad8bf3320e3bc86879a8b1c692ad06bd324f6c6127 |
|
MD5 | f836e97a19cab5df458ba366d35b4d7c |
|
BLAKE2b-256 | bcea00511d3d7d5508ac6076b69a7566284fba560ffb966b7daf6391d9783603 |
Hashes for aiokafka-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e957b42ae959365efbb45c9b5de38032c573608553c3670ad8695cc210abec9 |
|
MD5 | 86adc72b95b7fff737bd0542d80adcc2 |
|
BLAKE2b-256 | c306a4f9e4b0142bef2f38f5209bf54db219724c1a999155b03b17305923bea5 |
Hashes for aiokafka-0.11.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d519bf9875ac867fb19d55de3750833b1eb6379a08de29a68618e24e6a49fc0 |
|
MD5 | fe2fb5058ca7aad1ad0c82e8bd640562 |
|
BLAKE2b-256 | 61c5f678b815bfe84c40775075b01c3fd956706eab0097083eea1c47336b78cb |
Hashes for aiokafka-0.11.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d80590c4ef0ba546a299cee22ea27c3360c14241ec43a8e6904653f7b22d328 |
|
MD5 | e5f61e0cbbdb8217d9231b97446e3ade |
|
BLAKE2b-256 | bb63477d380af21a89cb3491608dc9e2f99361570ded895fcb12b67a45374a16 |
Hashes for aiokafka-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 516e1d68d9a377860b2e17453580afe304605bc71894f684d3e7b6618f6f939f |
|
MD5 | e64295f8a9f7a03c8c2058994efc678a |
|
BLAKE2b-256 | 9607c260fd905435175da6634646a02fcb8ddfe89a755b5c75c9046d14afd526 |
Hashes for aiokafka-0.11.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38e1917e706c1158d5e1f612d1fc1b40f706dc46c534e73ab4de8ae2868a31be |
|
MD5 | 6dd96b2b8882145e79bfc3088b84178d |
|
BLAKE2b-256 | b4ffae8146b6b91536a84bd58806480e50968033c7850d7b4c6fbc3eec103fb0 |
Hashes for aiokafka-0.11.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acfd0a5d0aec762ba73eeab73b23edce14f315793f063b6a4b223b6f79e36bb8 |
|
MD5 | a83b5e0730186a9dcd18d92cca407fd1 |
|
BLAKE2b-256 | f0d35f8b98406625cc89d5ad2659a0a11d325490e82bc1519aa2f311359aa432 |
Hashes for aiokafka-0.11.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 926f93fb6a39891fd4364494432b479c0602f9cac708778d4a262a2c2e20d3b4 |
|
MD5 | 98dba76fcb661cbe456b8d38bd6d76ec |
|
BLAKE2b-256 | 2652740beb52f9cfdd2ca9491f136534a76a6ad4c75a76fd12fdb90dc8da1afd |
Hashes for aiokafka-0.11.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 702aec15b63bad5e4476294bcb1cb177559149fce3e59335794f004c279cbd6a |
|
MD5 | e2c450c21567061ce2c52ffe336e4dd7 |
|
BLAKE2b-256 | f9aeed6fb775a60eca018ea38ac5c6d6852775f922c8503c905761752980e4cb |
Hashes for aiokafka-0.11.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d59fc7aec088c9ffc02d37e61591f053459bd11912cf04c70ac4f7e60405667d |
|
MD5 | 800b7a469195c60e14ab03418d86b1e5 |
|
BLAKE2b-256 | 5f7a89e726a20f9c7b994b0f0f78339a7f31a72d925dc4e7a5b673f71ffc7868 |
Hashes for aiokafka-0.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaafe134de57b184f3c030e1a11051590caff7953c8bf58048eefd8d828e39d7 |
|
MD5 | 63b8990834f81978eb9b3055dc8bc870 |
|
BLAKE2b-256 | f9336683d32e05aa11a65841f146f3e220cd6319618909463c62feed0a7a881f |
Hashes for aiokafka-0.11.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c85f66eb3564c5e74d8e4c25df4ac1fd94f1a6f6e66f005aafa6f791bde215 |
|
MD5 | 95dc575c0a724c30213d18f42d6c695e |
|
BLAKE2b-256 | 201420ea593481a8fe5d5d386f95bde74badef76fb3392d06c288473efb9e169 |
Hashes for aiokafka-0.11.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 807f699cf916369b1a512e4f2eaec714398c202d8803328ef8711967d99a56ce |
|
MD5 | 1da2befaf34898392db36c62d2aaf47c |
|
BLAKE2b-256 | fc08c9e0ae9b1a01932e27dbb9bf62cc26e1057ed132fcd52a99886aa8d151f0 |
Hashes for aiokafka-0.11.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 419dd28c8ed6e926061bdc60929af08a6b52f1721e1179d9d21cc72ae28fd6f6 |
|
MD5 | 0132fb5de5fb6271ea1e1b3fc682bd09 |
|
BLAKE2b-256 | 9468b5324296c60bae768c3b8e5638636df0179cd53205ec4ebdcedfce8ef472 |
Hashes for aiokafka-0.11.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d724b6fc484e453b373052813e4e543fc028a22c3fbda10e13b6829740000b8a |
|
MD5 | 48cecb1bf7232cc1d74cb6c899ead35c |
|
BLAKE2b-256 | 9a1164b4183b6ce6ddff98f95ca1bbdd49f971dca6c5155081a303b126c4bbb5 |
Hashes for aiokafka-0.11.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73584be8ba7906e3f33ca0f08f6af21a9ae31b86c6b635b93db3b1e6f452657b |
|
MD5 | 01540da95e7ae99b1d38509259e7f25c |
|
BLAKE2b-256 | 45ffe0653d063673826b9d776976fc5767295d4d475a05ef65e82aa4c5f396d3 |
Hashes for aiokafka-0.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 230170ce2e8a0eb852e2e8b78b08ce2e29b77dfe2c51bd56f5ab4be0f332a63b |
|
MD5 | 048ecff687e8b24dc019db2cabb8ceff |
|
BLAKE2b-256 | 4e191f781d5616b54cb8d8c7e80953a6daa2e3cf6f3ed27903c8815362d8a978 |
Hashes for aiokafka-0.11.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee0c61a2dcabbe4474ff237d708f9bd663dd2317e03a9cb7239a212c9ee05b12 |
|
MD5 | b9fe921baadae3b78121cf36bb9ae857 |
|
BLAKE2b-256 | d9576d5e77fdc655fefddd36eaf2dde5cd39deb5a56e4ac9a8f3d207a196b535 |
Hashes for aiokafka-0.11.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eac78a009b713e28b5b4c4daae9d062acbf2b7980e5734467643a810134583b5 |
|
MD5 | d81580050cade796c4c69d4a1e5b0675 |
|
BLAKE2b-256 | a44b27e5462378e202d443d26e240de1cd8a3e6a930a103c9e5912fc536e5726 |
Hashes for aiokafka-0.11.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0973a245b8b9daf8ef6814253a80a700f1f54d2da7d88f6fe479f46e0fd83053 |
|
MD5 | bd507f1218c91d1ce56db809a542755f |
|
BLAKE2b-256 | baaad1cc19ba3b26acc4727ec41267939cdf2db4e9519c87b2e3aec08a4a191b |