File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ from confluent_kafka import Producer , KafkaError , KafkaException
4
+ import time
5
+
6
+ seen_all_brokers_down = False
7
+
8
+ def error_cb (err ):
9
+ print ('error_cb' , err )
10
+ if err .code () == KafkaError ._ALL_BROKERS_DOWN :
11
+ global seen_all_brokers_down
12
+ seen_all_brokers_down = True
13
+
14
+
15
+ def test_error_cb ():
16
+ """ Test the error callback. """
17
+
18
+ global seen_all_brokers_down
19
+
20
+ # Configure an invalid broker and make sure the ALL_BROKERS_DOWN
21
+ # error is seen in the error callback.
22
+ p = Producer ({'bootstrap.servers' : '127.0.0.1:1' , 'socket.timeout.ms' :10 ,
23
+ 'error_cb' : error_cb })
24
+
25
+ t_end = time .time () + 5
26
+
27
+ while not seen_all_brokers_down and time .time () < t_end :
28
+ p .poll (1 )
29
+
30
+ assert seen_all_brokers_down
You can’t perform that action at this time.
0 commit comments