Skip to content

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

@ian-llewellyn ian-llewellyn commented May 25, 2023

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)

@ian-llewellyn

Copy link
Copy Markdown
Contributor Author

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

@andrewleech

Copy link
Copy Markdown
Contributor

Those examples look great!

@ian-llewellyn

Copy link
Copy Markdown
Contributor Author

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

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

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.

@ian-llewellyn

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.

@ian-llewellyn

Copy link
Copy Markdown
Contributor Author

Just polling to see if this can go ahead.

@ian-llewellyn

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 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.

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 dpgeorge force-pushed the umqtt.robust.connect branch from 1d1f6ac to 3b51e30 Compare July 1, 2026 05:13
@dpgeorge dpgeorge merged commit 3b51e30 into micropython:master Jul 1, 2026
4 of 5 checks passed
@dpgeorge

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 👍

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