Closed gwthm-in closed 7 years ago
Sorry for offtop, but it's better to use async version of kafka here: https://github.com/aio-libs/aiokafka About the error, is your kafka-related code work without any frameworks?
@imbolc
Yes, it works without any framework. And recently I found it is not working with Sanic. Sometime it is working and sometimes it is not.
Thanks for suggesting it, I'll try that and get back to you.
@imbolc I think, the problem with the event loops. Kafka using it's own loop and Japronto as well.
So, aiokafka works well?
@imbolc I didn't test it yet as I don't have any benchmarks with aiokafka. But surely I'll try to test that. Do you have any branch marks
@squeaky-pl
Hey I guess, this might be the issue. I'm really not sure. But just a guess. The problem is async libs uses their own loops and Japronto uses it's own loops. So, I think because of the early created object is not reachable with in the server code.
I was testing it with Sanic. I found the same issue. I debugged a little there and instead of the above way, I created the producer before the server starts and hooked it to app object. Booomm..! So , it is accessible with all works via app.producer.
I think Japronto needs some workaround this, middleware or before and after starts. Or even getting the event loops or sharing the loop. Meanwhile it work like a charm with non-async modules.
Anyway thanks for such a great python beast! 👍
@Gowtham95india Getting many different event loops to cooperate is non trivial (I dont know what kafka driver uses there). You can always overcome those issues with threads and threadexecutors but this makes code harder to follow. I plan on providing before/after fork hooks and customer worker subclasses to address those things but I consider this "end-user sugar candy". And while this is important to have I need to first get the inner guts right because once you start adding those convenience things on top tweaking the inner guts will no longer be possible.
@squeaky-pl Yea,, Yup that's true, I agree on that.
I really didn't understand what is causing the issue here. I have initialised producer like below. But when we call the request is failing. But the same thing if we execute in terminal or same structured code in Sanic is working fine.
Any ideas or suggestions to fix this?
Error
I don't think it is because of timeout as I tried it with 10 seconds. It didn't work. Any ideas it is failing ?