@@ -25,11 +25,8 @@ Example of AIOKafkaProducer usage:
25
25
from aiokafka import AIOKafkaProducer
26
26
import asyncio
27
27
28
- loop = asyncio.get_event_loop()
29
-
30
28
async def send_one ():
31
- producer = AIOKafkaProducer(
32
- loop = loop, bootstrap_servers = ' localhost:9092' )
29
+ producer = AIOKafkaProducer(bootstrap_servers = ' localhost:9092' )
33
30
# Get cluster layout and initial topic/partition leadership information
34
31
await producer.start()
35
32
try :
@@ -39,14 +36,14 @@ Example of AIOKafkaProducer usage:
39
36
# Wait for all pending messages to be delivered or expire.
40
37
await producer.stop()
41
38
42
- loop.run_until_complete (send_one())
39
+ asyncio.run (send_one())
43
40
44
41
45
42
AIOKafkaConsumer
46
43
****************
47
44
48
45
AIOKafkaConsumer is a high-level, asynchronous message consumer.
49
- It interacts with the assigned Kafka Group Coordinator node to allow multiple
46
+ It interacts with the assigned Kafka Group Coordinator node to allow multiple
50
47
consumers to load balance consumption of topics (requires kafka >= 0.9.0.0).
51
48
52
49
Example of AIOKafkaConsumer usage:
@@ -56,12 +53,10 @@ Example of AIOKafkaConsumer usage:
56
53
from aiokafka import AIOKafkaConsumer
57
54
import asyncio
58
55
59
- loop = asyncio.get_event_loop()
60
-
61
56
async def consume ():
62
57
consumer = AIOKafkaConsumer(
63
58
' my_topic' , ' my_other_topic' ,
64
- loop = loop, bootstrap_servers = ' localhost:9092' ,
59
+ bootstrap_servers = ' localhost:9092' ,
65
60
group_id = " my-group" )
66
61
# Get cluster layout and join group `my-group`
67
62
await consumer.start()
@@ -74,7 +69,7 @@ Example of AIOKafkaConsumer usage:
74
69
# Will leave consumer group; perform autocommit if enabled.
75
70
await consumer.stop()
76
71
77
- loop.run_until_complete (consume())
72
+ asyncio.run (consume())
78
73
79
74
Running tests
80
75
-------------
0 commit comments