FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

umqtt.robust: let reconnect() call the connect() method of the top class by ian-llewellyn · Pull Request #669 · micropython/micropython-lib · GitHub

umqtt.robust: let reconnect() call the connect() method of the top class - #669

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
ian-llewellyn:umqtt.robust.connect
Jul 1, 2026
Merged

umqtt.robust: let reconnect() call the connect() method of the top class#669
dpgeorge merged 1 commit into
micropython:masterfrom
ian-llewellyn:umqtt.robust.connect

Conversation

ian-llewellyn commented May 25, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

This allows overriding of the connect() method by a subclass as per the included examples: example_lwt_robust.py and example_resubscribe_robust.py.

Fixes #186, #321 (by enabling example_resubscribe_robust.py)
Supersedes PR #195 (original source file moved, examples added)

Copy link
Copy Markdown
Contributor Author

@andrewleech, if you had a moment to review + comment, I'd appreciate it.

Copy link
Copy Markdown
Contributor

Those examples look great!

Copy link
Copy Markdown
Contributor Author

Anything else I ought to do / address before this can go forward for merge?

ian-llewellyn force-pushed the umqtt.robust.connect branch from 8d4503b to 1d1f6ac Compare June 6, 2023 16:15

Copy link
Copy Markdown
Contributor Author

Hey guys, any chance we can progress this to merge? If there's anything else to do beforehand, let me know.

Copy link
Copy Markdown
Contributor Author

@andrewleech, @dpgeorge, you guys seem like the people to be pestered! 🤣 (sorry). Are there reasons this PR shouldn't progress? If there's anything more I should do, please do tell.

Copy link
Copy Markdown
Contributor Author

Just polling to see if this can go ahead.

Copy link
Copy Markdown
Contributor Author

This change allows reconnect() to respect subclass overrides of connect(), which aligns with normal Python polymorphism and enables common extension patterns (e.g. setting LWT state or re-subscribing after reconnect as per examples).

Currently, using super().connect() bypasses such overrides, meaning subclasses cannot reliably customise connection behaviour during reconnects.

This PR does assume that connect() will never call reconnect(). If that contract is expected, this seems like the more extensible approach; if not, the current implementation is safer but restricts subclass behaviour.

Happy to leave as-is if the intention is to keep reconnect() tied strictly to the base implementation. Would love to close this PR if that is the case.

dpgeorge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry this PR got neglected. In the meantime I merged #195 (which actually rebased cleanly). This PR is still useful because it adds a comment and some very helpful examples.

Follow up to commit 5dad29e.

Add a comment on how to override the `connect()` method by a subclass, and
provide examples: `example_lwt_robust.py` and
`example_resubscribe_robust.py`.

Co-authored by: Ian Cotter-Llewellyn <ian_llewellyn@hotmail.com>
Date: Thu May 25 11:42:20 2023 +0100
dpgeorge force-pushed the umqtt.robust.connect branch from 1d1f6ac to 3b51e30 Compare July 1, 2026 05:13
dpgeorge merged commit 3b51e30 into micropython:master Jul 1, 2026
4 of 5 checks passed

dpgeorge commented Jul 1, 2026

Copy link
Copy Markdown
Member

This is now rebased and merged.

Thanks @ian-llewellyn for persisting with this for so long 👍

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL