Skip to content

Commit bb3be53

Browse files
move on_matching_status_update to matching listener declaration
1 parent 95d9e88 commit bb3be53

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

examples/z_pub.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
import zenoh
1818

1919

20-
def on_matching_status_update(status: zenoh.MatchingStatus):
21-
if status.matching:
22-
print("Publisher has matching subscribers.")
23-
else:
24-
print("Publisher has NO MORE matching subscribers")
25-
26-
2720
def main(
2821
conf: zenoh.Config,
2922
key: str,
@@ -41,6 +34,13 @@ def main(
4134
pub = session.declare_publisher(key)
4235

4336
if add_matching_listener:
37+
38+
def on_matching_status_update(status: zenoh.MatchingStatus):
39+
if status.matching:
40+
print("Publisher has matching subscribers.")
41+
else:
42+
print("Publisher has NO MORE matching subscribers")
43+
4444
pub.declare_matching_listener(on_matching_status_update)
4545

4646
print("Press CTRL-C to quit...")

examples/z_querier.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818
import zenoh
1919

2020

21-
def on_matching_status_update(status: zenoh.MatchingStatus):
22-
if status.matching:
23-
print("Querier has matching queryables.")
24-
else:
25-
print("Querier has NO MORE matching queryables")
26-
27-
2821
def main(
2922
conf: zenoh.Config,
3023
selector: str,
@@ -46,6 +39,13 @@ def main(
4639
)
4740

4841
if add_matching_listener:
42+
43+
def on_matching_status_update(status: zenoh.MatchingStatus):
44+
if status.matching:
45+
print("Querier has matching queryables.")
46+
else:
47+
print("Querier has NO MORE matching queryables")
48+
4949
querier.declare_matching_listener(on_matching_status_update)
5050

5151
print("Press CTRL-C to quit...")

0 commit comments

Comments
 (0)