Skip to content

Python: status_subscriber.get(timeout) causes TypeError #322

Description

@awelzel

Using .get() providing a timeout on a StatusSubscriber causes TypeError splash:

In [6]: ss = ep.make_status_subscriber(True)
In [7]: ss.get(0.5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: Unregistered type : std::optional<std::variant<broker::none, broker::error, broker::status> >

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-4fcab5cf726a> in <module>
----> 1 ss.get(0.1)

/opt/zeek-dev-prod/lib/zeek/python/broker/__init__.py in get(self, *args, **kwargs)
    208 
    209     def get(self, *args, **kwargs):
--> 210         x = self._subscriber.get(*args, **kwargs)
    211         return self._to_result(x)
    212 

TypeError: Unable to convert function return value to a Python type! The signature was
        (self: broker._broker.StatusSubscriber, arg0: float) -> std::optional<std::variant<broker::none, broker::error, broker::status> >

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

This works fine with a normal subscriber with a 0.5 second delay:

In [13]: ss = ep.make_subscriber("/topic/test")

In [14]: r = ss.get(0.5)

In [15]: print(repr(r))
None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions