broadcaster icon indicating copy to clipboard operation
broadcaster copied to clipboard

Kafka test hangs on "await subscriber.get()"

Open rafalp opened this issue 4 years ago • 2 comments

We now have tests suite courtesy of #11, but test for Kafka backend hands indefinitely on await subscriber.get(), causing tests suite to timeout:

https://github.com/encode/broadcaster/blob/435c35eefcf54192331a44881caf626a5993b2f0/tests/test_broadcast.py#L43

Sadly, I'm out of my depth here, and I'm unable to diagnose if this is problem with Kafka backend or test setup.

Help is welcome.

rafalp avatar Mar 21 '21 20:03 rafalp

Maybe unrelated, but there's something strange about the subscribe/unsubscribe implementations in the Kafka backend:

https://github.com/encode/broadcaster/blob/master/broadcaster/_backends/kafka.py

Essentially when we subscribe to a new channel, we add it to a set of channels, then get the Kafka consumer to subscribe to all those channels (topics). And when we unsubscribe from a specific channel, we unsubscribe, period. I wonder if this can cause issues when subscribing from two or more channels independently. Probably not related to the test though since we only subscribe to a si single "chatroom" channel there.

Anyway, one way to narrow it down would be to look if it hangs on getting an item from the internal subscriber queue, or perhaps more specifically waiting for the "getone()" operation on the Kafka consumer to return an item. In the latter case it might be that the topic hasn't actually received the message, ie that the publish() operation didn't work correctly. If I remember correctly Kafka producers typically have an internal buffer that they don't necessarily flush right away (Kafka was designed for high volume streaming use cases). Perhaps we need to force-flush that, or something?

florimondmanca avatar Mar 21 '21 23:03 florimondmanca

Some experimentation result mentioned in https://github.com/encode/broadcaster/issues/44#issuecomment-956094210 seems the issue is with test.

justinepdevasia avatar Nov 01 '21 10:11 justinepdevasia