Open
Conversation
…e control during on publish
bretambrose
reviewed
Mar 19, 2026
| if puback_taken: | ||
| raise RuntimeError( | ||
| "acquire_publish_acknowledgement_control() may only be called once per received PUBLISH.") | ||
| if not callback_active: |
Contributor
There was a problem hiding this comment.
does this need nonlocal declaration too?
|
|
||
| if puback_control_id != 0: | ||
| def acquire_publish_acknowledgement_control(): | ||
| nonlocal puback_taken |
Contributor
There was a problem hiding this comment.
do we need synchronization support to be thread-safe here? Even though we're in the client's callback, it's still possible for this value to cross thread boundaries and this to be invoked concurrently.
| return | ||
| self._on_publish_cb(publish_data) | ||
|
|
||
| callback_active = False |
Contributor
There was a problem hiding this comment.
I thought we were going to call acquire_publish_acknowledgement_control here to prevent calls to it from succeeding after we exit the callback?
|
|
||
| /* If _on_publish returned False/None, the user did not take control of the publish acknowledgement. | ||
| * Auto-invoke it now. */ | ||
| if (puback_control_id != 0 && !PyObject_IsTrue(result)) { |
Contributor
There was a problem hiding this comment.
can't you combine these two (remove the top one) by changing this to
if (puback_control_id != 0 && (!result || !PyObject_IsTrue(result)) {
...
}
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bind manual puback
Opaque manual puback control handle
Tests for Manual Puback
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.