-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
some question that belongs on stackoverflow #82
Comments
Thanks for opening this issue. 👍 Let me have a look. :)
Yes, I do. :) It was a design mistake on my part. Use the context manager interface instead.
Don't. :) It's an anti-pattern.
Luckily for you, it is feasible. I assume that you use something like FastAPI. It supports context manager dependencies through dependency injection. This way, you can tie the lifetime of your single Learn to love (async) context managers in python. They may seem like unnecessary boilerplate at first but they are definitely worth it in the long run. Just take my word for it. :) Now to the actual issue at hand here: Reconnection.
Yes, this is something that really makes paho-mqtt user friendly. Unfortunately, we (asyncio-mqtt) don't support automatic reconnection (yet). It's a trade-off between user friendliness and design complexity. IMHO, it's not worth the design complexity. I want to keep asyncio-mqtt lean—just a small wrapper around paho-mqtt. Otherwise, I don't have the bandwidth to maintain it. Simple as that. :) If someone joins us (asyncio-mqtt) and share the maintenance burden, then we can consider automatic reconnection. 👍 Some of the required changes just on the top of my mind:
If anyone us up for this, feel free to open a PR. 👍 |
You're right. I thought it was scoped to the application but it seems that it's scoped to each request.
I welcome anyone to make a pull request that adds this example. :) Your question is about scoping and life time management. In other words, it's a question about how asyncio tasks work in general (and Python scope rules and import system in general). You need to find support for this elsewhere (e.g., stackoverflow.com). asyncio-mqtt provides a general-purpose context manager interface. That is good enough for any use case. It's up to the user (you) to build on top of that. Yes, that currently includes reconnecting, connection pooling, etc. Whether your framework of choice (e.g., FastAPI) helps you with that or not is outside the scope of asyncio-mqtt. This issue tracker is for specific bottlenecks/design choices/bugs in asyncio-mqtt that prevents you to build on top of it. I'll gladly review/accept PRs that improves these things. 👍 This issue tracker is not for how python and asyncio works in general. I just don't have the bandwidth to answer general-purpose python/asyncio questions. I wish I had time for that but unfortunately I don't. :) Don't worry, there are other places (stackoverflow) where people seem to have plenty of time to answer your questions. 👍 I'll keep this issue open to address the issue of automatic reconnection because I think many people expect that. 👍 Hopefully, someone wants to make a PR for the development and maintenance of this feature. :) |
Let's keep it constructive here. 👍 I'll re-open the issue to keep track of the reconnection feature. Again, if anyone searches for this, PRs are welcome. :) |
No description provided.
The text was updated successfully, but these errors were encountered: