> -----Original Message----- > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > Certain polling APIs in the standard library - most notably: the > select() function and the poll class - allow to poll any object that implements > the fileno() method returning the underlying file descriptor number. > > Implement fileno() for Chip and LineRequest which allows users to do: > > rd, _, _ = select([chip/request], [], [], 1) > > where rd will contain the actual object passed to select which makes for > easier reading of events afterwards. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > +class PollLineRequestObject(TestCase): > + def setUp(self) -> None: > + self.sim = gpiosim.Chip(num_lines=8) > + self.request = gpiod.request_lines( > + self.sim.dev_path, {2: > gpiod.LineSettings(edge_detection=Edge.BOTH)} > + ) > + self.thread: Optional[Thread] = None > + > + def tearDown(self) -> None: > + if self.thread: > + self.thread.join() > + del self.thread > + self.request.release() > + del self.request > + del self.sim > + > + def trigger_rising_edge(self, offset: int) -> None: > + time.sleep(0.05) > + self.sim.set_pull(offset, Pull.UP) > + > + def test_select_request_object(self): Nit: def test_select_request_object(self) -> None: > diff --git a/bindings/python/tests/tests_info_event.py > b/bindings/python/tests/tests_info_event.py > index e726a54..b3688f1 100644 > --- a/bindings/python/tests/tests_info_event.py > +++ b/bindings/python/tests/tests_info_event.py > @@ -7,6 +7,7 @@ import threading > import time > from dataclasses import FrozenInstanceError from functools import partial > +from select import select > from typing import Optional > from unittest import TestCase > > @@ -131,6 +132,23 @@ class WatchingInfoEventWorks(TestCase): > self.assertGreater(ts_rel, ts_rec) > self.assertGreater(ts_rec, ts_req) > > + def test_select_chip_object(self): Nit: def test_select_chip_object(self) -> None: These fail `mypy --strict` otherwise. These are optional checks so I'll leave it up to you to decide if you want to implement them. Otherwise- Reviewed-by: Vincent Fazio <vfazio@xxxxxxxxxxx>