@@ -287,30 +287,30 @@ def test_producer_bool_value():
287
287
288
288
def test_callback_exception_no_system_error ():
289
289
delivery_reports = []
290
-
290
+
291
291
def delivery_cb_that_raises (err , msg ):
292
292
"""Delivery report callback that raises an exception"""
293
293
delivery_reports .append ((err , msg ))
294
294
raise RuntimeError ("Test exception from delivery_cb" )
295
-
295
+
296
296
producer = Producer ({
297
297
'bootstrap.servers' : 'nonexistent-broker:9092' , # Will cause delivery failures
298
298
'socket.timeout.ms' : 100 ,
299
299
'message.timeout.ms' : 10 , # Very short timeout to trigger delivery failure quickly
300
300
'on_delivery' : delivery_cb_that_raises
301
301
})
302
-
302
+
303
303
# Produce a message - this will trigger delivery report callback when it fails
304
304
producer .produce ('test-topic' , value = 'test-message' )
305
-
305
+
306
306
# Flush to ensure delivery reports are processed
307
- # Before fix: Would get RuntimeError + SystemError
307
+ # Before fix: Would get RuntimeError + SystemError
308
308
# After fix: Should only get RuntimeError (no SystemError)
309
309
with pytest .raises (RuntimeError ) as exc_info :
310
310
producer .flush (timeout = 2.0 ) # Longer timeout to ensure delivery callback fires
311
-
311
+
312
312
# Verify we got an exception from our callback
313
313
assert "Test exception from delivery_cb" in str (exc_info .value )
314
-
314
+
315
315
# Verify the delivery callback was actually called
316
316
assert len (delivery_reports ) > 0
0 commit comments