79568464

Date: 2025-04-11 09:16:32
Score: 3
Natty:
Report link

I've been struggling with the same. The receive_batch() function never seems to yield control to another task. So it seems impossible to process the messages in the same thread, as I would have expected when using asyncio...

I only manage to stop the execution by calling client.close() function but that's quite drastic and it results in the same error as what you've shown.

Basically, it seems that an event processor is started (https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventhub/azure-eventhub/azure/eventhub/\_consumer_client.py#L449) and that function spawns a thread (https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/eventhub/azure-eventhub/azure/eventhub/\_eventprocessor/event_processor.py#L364) and keeps running forever (there's no easy mechanism to stop it). So there's no use of asyncio down there, and I don't even understand why we can call await client.receive() since it's not even an async function...

Have you found a better solution? As far as I can tell now, I'll need to implement threading and a message queue to transfer events to my actual processing thread.

Reasons:
  • RegEx Blacklisted phrase (2.5): Have you found a better solution
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Sebastiaan Merckx