Reimplement send_with_reply() using DBusPendingCall #86
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.
Current implementation of
send_with_reply()
relies onsend()
+ adding the returnedMessageReply
tomsg_handlers()
array. There are a few downsides to this approach.filter_message_cb()
not getting called until user addsMessageReply
tomsg_handlers()
, otherwise the message will be missed and the handler will live forever. I.e. it lacks atomicity.Error
replies at all, which means a leakedMessageReply
per every failed call.send_with_reply()
is inconvenient to use while looping withiter()
, because for some reasonmsg_handlers()
is a property ofConnectionItems
, notConnection
, so the idiomaticfor i in c.iter(1000)
means the currently actingConnectionItems
is consumed, and so one can't call itsmsg_handlers()
property from inside the loop, unless the loop is rewritten with manual use ofnext()
.This PR reimplements
send_with_reply()
in terms ofdbus_connection_send_with_reply()
andDBusPendingCall
, so that none of the above is an issue anymore.Downsides of this PR:
MessageReply
is removed altogether, andsend_with_reply()
has the return type changed. I.e. this is an API-breaking change.Things to consider: If signature change is OK, maybe we should consider exposing the
timeout
parameter ofdbus_connection_send_with_reply()
too.