This is an automated email from the ASF dual-hosted git repository.
astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new a72bb9af0 PROTON-2879: [Python] Added accessors to unsettled deliveries
a72bb9af0 is described below
commit a72bb9af04de85babf7d52b7f92feec9fd8378b4
Author: Andrew Stitcher <[email protected]>
AuthorDate: Fri Mar 21 18:03:00 2025 -0400
PROTON-2879: [Python] Added accessors to unsettled deliveries
Added unsettled delivery accessors to high level python binding.
Including a generator which should make iterating over all unsettled
deliveries of a link straightforward.
---
python/proton/_delivery.py | 11 ++++++++++-
python/proton/_endpoints.py | 26 ++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/python/proton/_delivery.py b/python/proton/_delivery.py
index 81f2fda3c..a4d3f3651 100644
--- a/python/proton/_delivery.py
+++ b/python/proton/_delivery.py
@@ -48,7 +48,8 @@ from cproton import (PN_ACCEPTED, PN_MODIFIED, PN_RECEIVED,
PN_REJECTED, PN_RELE
pn_transactional_disposition_get_id,
pn_transactional_disposition_set_id,
pn_transactional_disposition_get_outcome_type,
- pn_transactional_disposition_set_outcome_type)
+ pn_transactional_disposition_set_outcome_type,
+ pn_unsettled_next)
from ._condition import cond2obj, obj2cond, Condition
from ._data import dat2obj, obj2dat
@@ -659,6 +660,14 @@ class Delivery(Wrapper):
"""
pn_delivery_settle(self._impl)
+ @property
+ def unsettled_next(self) -> Optional['Delivery']:
+ """
+ The next unsettled delivery on the link or ``None`` if there are
+ no more unsettled deliveries.
+ """
+ return Delivery.wrap(pn_unsettled_next(self._impl))
+
@property
def aborted(self) -> bool:
"""
diff --git a/python/proton/_endpoints.py b/python/proton/_endpoints.py
index 38dde5e6d..f44b27b0b 100644
--- a/python/proton/_endpoints.py
+++ b/python/proton/_endpoints.py
@@ -54,7 +54,7 @@ from cproton import PN_CONFIGURATION, PN_COORDINATOR,
PN_DELIVERIES, PN_DIST_MOD
pn_terminus_is_dynamic, pn_terminus_outcomes, pn_terminus_properties,
pn_terminus_set_address, \
pn_terminus_set_distribution_mode, pn_terminus_set_durability,
pn_terminus_set_dynamic, \
pn_terminus_set_expiry_policy, pn_terminus_set_timeout,
pn_terminus_set_type, \
- pn_link_properties, pn_link_remote_properties
+ pn_link_properties, pn_link_remote_properties, pn_unsettled_head
from ._condition import cond2obj, obj2cond
from ._data import Data, dat2obj, obj2dat, PropertyDict, SymbolList
@@ -63,7 +63,7 @@ from ._exceptions import ConnectionException, EXCEPTIONS,
LinkException, Session
from ._handler import Handler
from ._transport import Transport
from ._wrapper import Wrapper
-from typing import Any, Dict, List, Optional, Union, TYPE_CHECKING
+from typing import Any, Dict, Generator, List, Optional, Union, TYPE_CHECKING
if TYPE_CHECKING:
from ._condition import Condition
@@ -888,6 +888,28 @@ class Link(Wrapper, Endpoint):
"""
return pn_link_unsettled(self._impl)
+ @property
+ def unsettled_head(self) -> Optional[Delivery]:
+ """
+ The first unsettled delivery for this link.
+
+ This operation will return the first unsettled delivery on the
+ link, or ``None`` if there are no unsettled deliveries.
+ """
+ return Delivery.wrap(pn_unsettled_head(self._impl))
+
+ @property
+ def unsettled_deliveries(self) -> Generator[Delivery]:
+ """
+ Returns a generator of unsettled deliveries for this link.
+
+ :return: Generator of unsettled deliveries.
+ """
+ delivery = self.unsettled_head
+ while delivery:
+ yield delivery
+ delivery = delivery.unsettled_next
+
@property
def credit(self) -> int:
"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]