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())
Documentation
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.12.0-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdc0a83eb386d2384325d6571f8ef65b4cfa205f8d1c16d7863e8d10cacd995a |
|
MD5 | 3ede50806193b6310f808cee40e1b8b1 |
|
BLAKE2b-256 | bf0d4cb57231ff650a01123a09075bf098d8fdaf94b15a1a58465066b2251e8b |
Hashes for aiokafka-0.12.0-cp313-cp313-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63875fed922c8c7cf470d9b2a82e1b76b4a1baf2ae62e07486cf516fd09ff8f2 |
|
MD5 | b83be5aa2e8e96c738e1b2e4a4511276 |
|
BLAKE2b-256 | 166541cc1b19e7dea623ef58f3bf1e2720377c5757a76d9799d53a1b5fc39255 |
Hashes for aiokafka-0.12.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08c84b3894d97fd02fcc8886f394000d0f5ce771fab5c498ea2b0dd2f6b46d5b |
|
MD5 | b13adfd865423564b9687916e30ad626 |
|
BLAKE2b-256 | d92069f913a76916e94c4e783dc7d0d05a25c384b25faec33e121062c62411fe |
Hashes for aiokafka-0.12.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c01abf9787b1c3f3af779ad8e76d5b74903f590593bc26f33ed48750503e7f7 |
|
MD5 | 8a8656776d02c605ab1eee98c0a02c23 |
|
BLAKE2b-256 | 6b670154551292ec1c977e5def178ae5c947773e921aefb6877971e7fdf1942e |
Hashes for aiokafka-0.12.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed991c120fe19fd9439f564201dd746c4839700ef270dd4c3ee6d4895f64fe83 |
|
MD5 | 35bf136cc4cc3b4c657f05afc01a7842 |
|
BLAKE2b-256 | d7c75237b3687198c2129c0bafa4a96cf8ae3883e20cc860125bafe16af3778e |
Hashes for aiokafka-0.12.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9e8ab97b935ca681a5f28cf22cf2b5112be86728876b3ec07e4ed5fc6c21f2d |
|
MD5 | 020d9bc62cf8606eb8be3bf318756797 |
|
BLAKE2b-256 | 3084f1f7e603cd07e877520b5a1e48e006cbc1fe448806cabbaa98aa732f530d |
Hashes for aiokafka-0.12.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdbd69ec70eea4a8dfaa5c35ff4852e90e1277fcc426b9380f0b499b77f13b16 |
|
MD5 | 3ab779e828c3575019c071a1575f0f0e |
|
BLAKE2b-256 | ef97e2513a0c10585e51d4d9b42c9dd5f5ab15dfe150620a4893a2c6c20f0f4a |
Hashes for aiokafka-0.12.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a907abcdf02430df0829ac80f25b8bb849630300fa01365c76e0ae49306f512 |
|
MD5 | 93a0e7cb8bb48dff49121f74b874f2d3 |
|
BLAKE2b-256 | 993f75bd0faa77dfecce34dd1c0edd317b608518b096809736f9987dd61f4cec |
Hashes for aiokafka-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7b815b2e5fed9912f1231be6196547a367b9eb3380b487ff5942f0c73a3fb5c |
|
MD5 | 9e0b0221542b2c1b97d26ad8460da066 |
|
BLAKE2b-256 | ae48541ccece0e593e24ee371dec0c33c23718bc010b04e998693e4c19091258 |
Hashes for aiokafka-0.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 577c1c48b240e9eba57b3d2d806fb3d023a575334fc3953f063179170cc8964f |
|
MD5 | d7873df33593cf8e50fc01e8ca2b7fbb |
|
BLAKE2b-256 | 80f20ddaaa11876ab78e0f3b30f272c62eea70870e1a52a5afe985c7c1d098e1 |
Hashes for aiokafka-0.12.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3c8ec1c0606fa645462c7353dc3e4119cade20c4656efa2031682ffaad361c0 |
|
MD5 | 3a27b16dc78ff4211d19edc0eaa4d423 |
|
BLAKE2b-256 | 54ac653070a4add8beea7aa8209ab396de87c7b4f9628fff15efcdbaea40e973 |
Hashes for aiokafka-0.12.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b01947553ff1120fa1cb1a05f2c3e5aa47a5378c720bafd09e6630ba18af02aa |
|
MD5 | 542f536f695e0689d38b679a56e4407f |
|
BLAKE2b-256 | 53d4baf1b2389995c6c312834792329a1993a303ff703ac023250ff977c5923b |
Hashes for aiokafka-0.12.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04c8ad27d04d6c53a1859687015a5f4e58b1eb221e8a7342d6c6b04430def53e |
|
MD5 | e48d1f0d556db5476c52038b080f5e84 |
|
BLAKE2b-256 | 12e6101e7b13e1a4bce745be927bcecf7d9dddd68c57bbd876e31697e60fdc8d |
Hashes for aiokafka-0.12.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90511a2c4cf5f343fc2190575041fbc70171654ab0dae64b3bbabd012613bfa7 |
|
MD5 | e42b368b09f7796665d68696e5e23449 |
|
BLAKE2b-256 | f94ee7a4900180ff18f8468b1a1d6da821f67162409aa86eb53fdcb6bb1c5016 |
Hashes for aiokafka-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42b2436c7c69384d210e9169fbfe339d9f49dbdcfddd8d51c79b9877de545e33 |
|
MD5 | 316c38d8a6fe3b4988049d375a568f7e |
|
BLAKE2b-256 | dc42607caffc39b1fb2be288fa2c72e72b352872362699b6e7473189fee065b9 |
Hashes for aiokafka-0.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24633931e05a9dc80555a2f845572b6845d2dcb1af12de27837b8602b1b8bc74 |
|
MD5 | 3d18b2318e90883ebdc60f845fc97eba |
|
BLAKE2b-256 | 7dbcc5d2315e2f04768f585e31e6bd0a1fb9ed054a54c124c17087fdff507a13 |
Hashes for aiokafka-0.12.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff63689cafcd6dd642a15de75b7ae121071d6162cccba16d091bcb28b3886307 |
|
MD5 | 97512f0078223e178303228a381f9579 |
|
BLAKE2b-256 | fe6cc1ce38a225dfa04078f29d8734f13e483146cc2e30dbf6d13b75c2aa0724 |
Hashes for aiokafka-0.12.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddc5308c43d48af883667e2f950a0a9739ce2c9bfe69a0b55dc234f58b1b42d6 |
|
MD5 | 8f04f7329499676948539178f9f67af6 |
|
BLAKE2b-256 | b37b8faf3ae26f43b2dcc66f45665bd243c9f736e71df04e45da5836bb7a7be4 |
Hashes for aiokafka-0.12.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06f5889acf8e1a81d6e14adf035acb29afd1f5836447fa8fa23d3cbe8f7e8608 |
|
MD5 | c06fe0e055be7763ae0d02825bbab191 |
|
BLAKE2b-256 | 188373c54b884cf7dabe8ed5d5764e10a0ebec14c1efc19b8f243c8036963006 |
Hashes for aiokafka-0.12.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1158e630664d9abc74d8a7673bc70dc10737ff758e1457bebc1c05890f29ce2c |
|
MD5 | 3f8eb78c7d08c98708fcda4eb4807a59 |
|
BLAKE2b-256 | c746e7069d7359c77768f31629d6aa0c8d964a6942f22d74587a8944775894da |
Hashes for aiokafka-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d87b1a45c57bbb1c17d1900a74739eada27e4f4a0b0932ab3c5a8cbae8bbfe1e |
|
MD5 | 83ae8f7a4ccee8fe8983303776fee323 |
|
BLAKE2b-256 | 685e65a87e1f7308ba2e23d8ca3e366f506c0bbcbbabc388b776c8a5c181bc3e |
Hashes for aiokafka-0.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea5710f7707ed12a7f8661ab38dfa80f5253a405de5ba228f457cc30404eb51 |
|
MD5 | c603848d6ccc4ab998688e422f40e268 |
|
BLAKE2b-256 | bb4e3325c3e6e9ad88f4009de67f36063f45fc719d7097a87f2547922945dbf0 |
Hashes for aiokafka-0.12.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5c827c8883cfe64bc49100de82862225714e1853432df69aba99f135969bb1b |
|
MD5 | dc4afc8711cc411a7ffba55c5e306212 |
|
BLAKE2b-256 | a53f41a5741335c28062721ce6f4d94c2b92931d55f06e6c28c569ecdafe4635 |
Hashes for aiokafka-0.12.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da8938eac2153ca767ac0144283b3df7e74bb4c0abc0c9a722f3ae63cfbf3a42 |
|
MD5 | da22c86b856a413512a6096fe4e14472 |
|
BLAKE2b-256 | 6de68e302c5e1a4460138e56e95bf0ab201e6554d83e490f120bc45f69ef7bb2 |
Hashes for aiokafka-0.12.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a57fda053acd1b88c87803ad0381a1d2a29d36ec561550d11ce9154972b8e23 |
|
MD5 | fc01150308ed2debd20be5eb538a4737 |
|
BLAKE2b-256 | 209e89f8b9ff21fddfe3041fae2a476cd3816a9208e84f5432669f1d6ae3d8c7 |
Hashes for aiokafka-0.12.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aab2767dcc8923626d8d60c314f9ba633563249cff71750db5d70b6ec813da2 |
|
MD5 | 183254adcebe7cca6a9f0feb43d4d7ba |
|
BLAKE2b-256 | 2df1e3a80998715f479fbe2c3ccba1ba2f02fd65c3a82c6605e63c4188b76e25 |
Hashes for aiokafka-0.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8ddff02b1e981083dff6d1a80d4502e0e83e0e480faf1f881766ca6f23e8d22 |
|
MD5 | ba34993d79ef477619b6aa4586d03904 |
|
BLAKE2b-256 | 5046f63298e15028abd42876af47fabfd5e55bcf2c91e2cd581428acd0feded1 |
Hashes for aiokafka-0.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f96d7fd8fdb5f439f7e7860fd8ec37870265d0578475e82049bce60ab07ca045 |
|
MD5 | 9d93618952da6c35c7290925e14af4ac |
|
BLAKE2b-256 | 36f5c94d6f60c1d32dca606b39d3915bcd8165ff8a9259837ffee11c5713dc75 |
Hashes for aiokafka-0.12.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c77f5953ff4b25c889aef26df1f28df66c58db7abb7f34ecbe48502e9a6d273 |
|
MD5 | 2daae8e73119aa0142a4f3f13b59a267 |
|
BLAKE2b-256 | d449c181d27e22e9042f5acc3dcc30799057c37ff593f037827d3bc97658cfd5 |
Hashes for aiokafka-0.12.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9590554fae68ec80099beae5366f2494130535a1a3db0c4fa5ccb08f37f6e46 |
|
MD5 | 00605e33a7876a4ff6bb9b4b459e9ce3 |
|
BLAKE2b-256 | 402254ff080c72e53d1b1fe7dc9caf199b03eefbbf1fddb6654510f855447b2f |