Skip to content

Commit 321f46b

Browse files
committed
Remove Pull Subscriber.
Signed-off-by: ChenYing Kuo <evshary@gmail.com>
1 parent 1516153 commit 321f46b

File tree

5 files changed

+3
-99
lines changed

5 files changed

+3
-99
lines changed

docs/index.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ Subscriber
139139
.. autoclass:: zenoh.Subscriber
140140
:members:
141141

142-
PullSubscriber
143-
--------------
144-
.. autoclass:: zenoh.PullSubscriber
145-
:members:
146-
147142
Reliability
148143
-----------
149144
.. autoclass:: zenoh.Reliability

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ fn zenoh(_py: Python, m: &PyModule) -> PyResult<()> {
7777
m.add_class::<session::_Session>()?;
7878
m.add_class::<session::_Publisher>()?;
7979
m.add_class::<session::_Subscriber>()?;
80-
m.add_class::<session::_PullSubscriber>()?;
8180
m.add_class::<session::_Scout>()?;
8281
m.add_class::<queryable::_Query>()?;
8382
m.add_class::<queryable::_Queryable>()?;

src/session.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use zenoh::{
2323
prelude::{sync::SyncResolve, SessionDeclarations},
2424
publication::Publisher,
2525
scouting::Scout,
26-
subscriber::{PullSubscriber, Subscriber},
26+
subscriber::Subscriber,
2727
Session,
2828
};
2929

@@ -226,30 +226,6 @@ impl _Session {
226226
Ok(_Subscriber(subscriber))
227227
}
228228

229-
#[pyo3(signature = (key_expr, callback, **kwargs))]
230-
pub fn declare_pull_subscriber(
231-
&self,
232-
key_expr: &_KeyExpr,
233-
callback: &PyAny,
234-
kwargs: Option<&PyDict>,
235-
) -> PyResult<_PullSubscriber> {
236-
let callback: PyClosure<(_Sample,)> = <_ as TryInto<_>>::try_into(callback)?;
237-
let mut builder = self
238-
.0
239-
.declare_subscriber(&key_expr.0)
240-
.pull_mode()
241-
.with(callback);
242-
if let Some(kwargs) = kwargs {
243-
match kwargs.extract_item::<_Reliability>("reliability") {
244-
Ok(reliabilty) => builder = builder.reliability(reliabilty.0),
245-
Err(crate::ExtractError::Other(e)) => return Err(e),
246-
_ => {}
247-
}
248-
}
249-
let subscriber = builder.res().map_err(|e| e.to_pyerr())?;
250-
Ok(_PullSubscriber(subscriber))
251-
}
252-
253229
pub fn zid(&self) -> _ZenohId {
254230
_ZenohId(self.0.zid())
255231
}
@@ -290,15 +266,6 @@ impl _Publisher {
290266
#[pyclass(subclass)]
291267
pub struct _Subscriber(Subscriber<'static, ()>);
292268

293-
#[pyclass(subclass)]
294-
pub struct _PullSubscriber(PullSubscriber<'static, ()>);
295-
#[pymethods]
296-
impl _PullSubscriber {
297-
fn pull(&self) -> PyResult<()> {
298-
self.0.pull().res_sync().map_err(|e| e.to_pyerr())
299-
}
300-
}
301-
302269
#[pyclass(subclass)]
303270
pub struct _Scout(Scout<()>);
304271

zenoh/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .zenoh import init_logger, scout as _scout
1515
from .keyexpr import IntoKeyExpr, IntoSelector, KeyExpr, Selector
1616
from .config import Config
17-
from .session import Session, Publisher, Subscriber, PullSubscriber, Info
17+
from .session import Session, Publisher, Subscriber, Info
1818
from .enums import CongestionControl, Encoding, Priority, QueryConsolidation, QueryTarget, Reliability, SampleKind
1919
from .value import Hello, Value, IntoValue, IValue, Sample, IntoSample, ZenohId, Timestamp, Reply
2020
from .closures import Closure, IClosure, IntoClosure, Handler, IHandler, IntoHandler, ListCollector, Queue

zenoh/session.py

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
from typing import Union, Any, List
1515

16-
from .zenoh import _Session, _Config, _Publisher, _Subscriber, _PullSubscriber
16+
from .zenoh import _Session, _Config, _Publisher, _Subscriber
1717

1818
from .keyexpr import KeyExpr, IntoKeyExpr, Selector, IntoSelector
1919
from .config import Config
@@ -66,34 +66,6 @@ def undeclare(self):
6666
self._subscriber_ = None
6767

6868

69-
class PullSubscriber:
70-
"""
71-
A handle to a pull subscription.
72-
73-
Its main purpose is to keep the subscription active as long as it exists.
74-
75-
When constructed through ``Session.declare_pull_subscriber(session, keyexpr, handler)``, it exposes ``handler``'s receiver
76-
through ``self.receiver``.
77-
78-
Calling ``self.pull()`` will prompt the Zenoh network to send a new sample when available.
79-
"""
80-
81-
def __init__(self, s: _PullSubscriber, receiver=None):
82-
self._subscriber_ = s
83-
self.receiver = receiver
84-
85-
def pull(self):
86-
"""
87-
Prompts the Zenoh network to send a new sample if available.
88-
Note that this sample will not be returned by this function, but provided to the handler's callback.
89-
"""
90-
self._subscriber_.pull()
91-
92-
def undeclare(self):
93-
"Undeclares the subscription"
94-
self._subscriber_ = None
95-
96-
9769
class Session(_Session):
9870
"""
9971
A Zenoh Session, the core interraction point with a Zenoh network.
@@ -342,35 +314,6 @@ def declare_subscriber(self, keyexpr: IntoKeyExpr, handler: IntoHandler[Sample,
342314
s = super().declare_subscriber(KeyExpr(keyexpr), handler.closure, **kwargs)
343315
return Subscriber(s, handler.receiver)
344316

345-
def declare_pull_subscriber(self, keyexpr: IntoKeyExpr, handler: IntoHandler[Sample, Any, Any], reliability: Reliability = None) -> PullSubscriber:
346-
"""
347-
Declares a pull-mode subscriber, which will receive a single published sample with a key expression intersecting ``keyexpr`` any time its ``pull`` method is called.
348-
349-
These samples are passed to the `handler`'s closure as instances of the `Sample` class.
350-
The `handler` can typically be a queue or a callback.
351-
The `handler`'s receiver is returned as the `receiver` field of the returned `PullSubscriber`.
352-
353-
:param keyexpr: The key expression to subscribe to
354-
:param handler:
355-
:param reliability: the reliability to use when routing the subscribed samples
356-
:rtype: PullSubscriber
357-
358-
:Examples:
359-
360-
>>> import zenoh
361-
>>> s = zenoh.open({})
362-
>>> sub = s.declare_pull_subscriber('key/expression', lambda sample:
363-
... print(f"Received '{sample.key_expr}': '{sample.payload.decode('utf-8')}'"))
364-
...
365-
>>> sub.pull()
366-
"""
367-
handler = Handler(handler, lambda x: Sample._upgrade_(x))
368-
kwargs = dict()
369-
if reliability is not None:
370-
kwargs['reliability'] = reliability
371-
s = super().declare_pull_subscriber(KeyExpr(keyexpr), handler.closure, **kwargs)
372-
return PullSubscriber(s, handler.receiver)
373-
374317
def close(self):
375318
"""Attempts to close the Session.
376319

0 commit comments

Comments
 (0)