|
13 | 13 | # |
14 | 14 | from typing import Union, Any, List |
15 | 15 |
|
16 | | -from .zenoh import _Session, _Config, _Publisher, _Subscriber, _PullSubscriber |
| 16 | +from .zenoh import _Session, _Config, _Publisher, _Subscriber |
17 | 17 |
|
18 | 18 | from .keyexpr import KeyExpr, IntoKeyExpr, Selector, IntoSelector |
19 | 19 | from .config import Config |
@@ -66,34 +66,6 @@ def undeclare(self): |
66 | 66 | self._subscriber_ = None |
67 | 67 |
|
68 | 68 |
|
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 | | - |
97 | 69 | class Session(_Session): |
98 | 70 | """ |
99 | 71 | A Zenoh Session, the core interraction point with a Zenoh network. |
@@ -342,35 +314,6 @@ def declare_subscriber(self, keyexpr: IntoKeyExpr, handler: IntoHandler[Sample, |
342 | 314 | s = super().declare_subscriber(KeyExpr(keyexpr), handler.closure, **kwargs) |
343 | 315 | return Subscriber(s, handler.receiver) |
344 | 316 |
|
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 | | - |
374 | 317 | def close(self): |
375 | 318 | """Attempts to close the Session. |
376 | 319 | |
|
0 commit comments