From ced90e79217793957b11414f47f8aa8a77c7a2d5 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 19 Sep 2023 11:31:42 +0200 Subject: [PATCH] bindings: python: tests: don't use the same chip from different threads There are no thread-safety guarantees in libgpiod. Let's not reuse the chip object created in one thread to generate info events in another but use a global request function instead. Reported-by: Erik Schilling Signed-off-by: Bartosz Golaszewski Reviewed-by: Erik Schilling --- bindings/python/tests/tests_info_event.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/python/tests/tests_info_event.py b/bindings/python/tests/tests_info_event.py index f3926d9..6bb09d5 100644 --- a/bindings/python/tests/tests_info_event.py +++ b/bindings/python/tests/tests_info_event.py @@ -37,9 +37,9 @@ class InfoEventDataclassBehavior(TestCase): event.line_info = 4 -def request_reconfigure_release_line(chip, offset): +def request_reconfigure_release_line(chip_path, offset): time.sleep(0.1) - with chip.request_lines(config={offset: None}) as request: + with gpiod.request_lines(chip_path, config={offset: None}) as request: time.sleep(0.1) request.reconfigure_lines( config={offset: gpiod.LineSettings(direction=Direction.OUTPUT)} @@ -95,7 +95,7 @@ class WatchingInfoEventWorks(TestCase): self.assertEqual(info.direction, Direction.INPUT) self.thread = threading.Thread( - target=partial(request_reconfigure_release_line, self.chip, 7) + target=partial(request_reconfigure_release_line, self.sim.dev_path, 7) ) self.thread.start() -- 2.30.2