[libcamera-devel] [PATCH v4 00/15] py: New python bindings event handling

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Thu Mar 9 15:25:46 CET 2023


Hi,

I sent the v3 of the series ("[PATCH v3 00/17] Python bindings event
handling") more than half a year ago. I've addressed the review comments
which I think make sense and are more or less obvious. In fact, I
made those changes quite soon after receiving them, again over half a
year ago. I also added some additional patches on top (the unittest
improvements).

But then I never had time to work on the biggest question, how to handle
the events, and so I never sent the v4. And then recently I added even
more patches on top. So I tought I'll just do a bit of work on the
series to introduce another way to manage the events, just as a hackish
RFC, and send the series. Perhaps there are more people interested in
the py bindings now, and we will get more discussion and ideas. I don't
want us to totally forget this series =).

So, here it is. The "py: New event handling" patch adds the events as in
v3. But in the topmost patch, "py: Hack for different event enable
mechanism" I draft another way we might handle the enabling and
disabling of the events.

One thing I didn't change was Laurent's comment that camera.stop()
should not return the disconnect events, only the request and buffer
completed events. I'm still not sure about that, but I think if we go
with the method I introduce in the topmost patch, it probably makes
sense to leave the disconnect events alone in camera.stop().

And, for those not familiar with the series: This changes the Python API
in a breaking manner. Changes to scripts using the Python bindings are
needed (see the "Use new events support" patches):

- Many methods throw exceptions now, instead of returning an error value
- The handling of events has changed. Previously it was all about
  request completed, and no other events. Now we support all the events.

 Tomi

Tomi Valkeinen (15):
  py: Use exceptions instead of returning error codes
  py: New event handling
  py: cam.py: Use new events support
  py: unittests.py: Use new events support
  py: simple-capture.py: Use new events support
  py: simple-continuous-capture.py: Use new events support
  py: simple-cam.py: Use new events support
  py: Drop get_ready_requests()
  py: Add hotplug-monitor.py
  py: unittests.py: Add weakref helpers and use del
  py: unittests.py: Add test for refs & keep-alives
  py: unittests.py: Fix type checker warnings
  py: Move Color Space and Transform classes to separate files
  py: Improve stub type generation for PyCameraEvent
  py: Hack for different event enable mechanism

 src/py/cam/cam.py                            |  44 +--
 src/py/examples/hotplug-monitor.py           |  39 +++
 src/py/examples/simple-cam.py                |  34 +--
 src/py/examples/simple-capture.py            |  36 ++-
 src/py/examples/simple-continuous-capture.py |  38 +--
 src/py/libcamera/meson.build                 |   2 +
 src/py/libcamera/py_camera_manager.cpp       | 180 +++++++++--
 src/py/libcamera/py_camera_manager.h         |  68 ++++-
 src/py/libcamera/py_color_space.cpp          |  71 +++++
 src/py/libcamera/py_main.cpp                 | 303 +++++++++++--------
 src/py/libcamera/py_transform.cpp            |  81 +++++
 test/py/unittests.py                         | 280 ++++++++++++-----
 12 files changed, 853 insertions(+), 323 deletions(-)
 create mode 100644 src/py/examples/hotplug-monitor.py
 create mode 100644 src/py/libcamera/py_color_space.cpp
 create mode 100644 src/py/libcamera/py_transform.cpp

-- 
2.34.1



More information about the libcamera-devel mailing list