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 7a559ba commit 107d638
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

1.2.8 | 2020-04-30 09:52:01 -0700

* Release v1.2.8

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

1.2.7 | 2020-04-10 16:16:06 -0700

* Release v1.2.6
* Release v1.2.7

* Change topic strings to not automaticaly alter slashes (Jon Siwek, Corelight)

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.2.8
============

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

Broker 1.2.7
============

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.7
1.2.8
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 broker/version.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using type = unsigned;

constexpr type major = 1;
constexpr type minor = 2;
constexpr type patch = 7;
constexpr type patch = 8;
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 107d638

Please sign in to comment.