Skip to content

Commit

Permalink
GH-109: fix unusable subscriber.poll() method in Python bindings
Browse files Browse the repository at this point in the history
(cherry picked from commit 182d6d1)
  • Loading branch information
jsiwek committed Apr 30, 2020
1 parent 7daed63 commit 72f69e8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

1.3.3 | 2020-04-30 09:50:24 -0700

* Release 1.3.3.

* GH-109: fix unusable subscriber.poll() method in Python bindings (Jon Siwek, Corelight)

1.3.2 | 2020-04-10 16:22:15 -0700

* Release 1.3.2.
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Broker 1.3.3
============

- Fix unusable subscriber.poll() method in Python bindings.

Broker 1.3.2
============

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.2
1.3.3
10 changes: 9 additions & 1 deletion bindings/python/_broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,15 @@ PYBIND11_MODULE(_broker, m) {
return rval;
})

.def("poll", &subscriber_base::poll)
.def("poll",
[](subscriber_base& ep) -> std::vector<topic_data_pair> {
auto res = ep.poll();
std::vector<topic_data_pair> rval;
rval.reserve(res.size());
for ( auto& e : res )
rval.emplace_back(std::make_pair(broker::get_topic(e), broker::get_data(e)));
return rval;
})
.def("available", &subscriber_base::available)
.def("fd", &subscriber_base::fd);

Expand Down
2 changes: 1 addition & 1 deletion include/broker/version.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using type = unsigned;

constexpr type major = 1;
constexpr type minor = 3;
constexpr type patch = 2;
constexpr type patch = 3;
constexpr auto suffix = "";

constexpr type protocol = 2;
Expand Down
13 changes: 12 additions & 1 deletion tests/python/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,18 @@ def test_ping(self):
self.assertEqual(d[0], "ping")

ep1.publish(t, ["pong"])
(t, d) = s2.get()

while True:
# This loop exists just for sake of test coverage for "poll()"
msgs = s2.poll()

if msgs:
self.assertEqual(len(msgs), 1)
(t, d) = msgs[0]
break;

time.sleep(0.1)

self.assertEqual(t, "/test")
self.assertEqual(d[0], "pong")

Expand Down

0 comments on commit 72f69e8

Please sign in to comment.